I'm trying to use an code example from ASPFree.com for use in .NET, but I get an error during the build. It involves adding records to a database. It can also be found here and here .
At any rate, the error I get in the code-behind is this: 'Execute' is not a System.Data.SqlClient.SqlCommand' for the line in red.
With this in mind, what is the proper way to phrase it so the program will run and a record will be added?
I believe this example was orignally done on the Beta 1 version so that might explain why it doesn't work in .NET 1.0
Here's the whole of the code (I transfered the code for the .htm pg to .aspx, and the code for the original .aspx pg to .vb)
ASPX code:
<html>
<body>
<form method="POST">
<p>Name: <input type="text" name="name" size="20"></p>
<p><input type="submit" value="ADD" name="B1">
<input type="reset" value="RESET" name="B2"></p>
</form>
</body>
</html>
VB Code-Behind [Sean is the theoretical DB, SQLAdd is the theoretical table and NAME is the theoretical column]:
Sub Page_Load(Src as Object, E as EventArgs )
Dim myConnection as SQLConnection
myConnection = new SQLConnection("SERVER=; UID=; PWD=; DATABASE=Sean"
Dim myCommand as SQLCommand
myCommand = new SQLCommand("INSERT into SQLAdd (NAME) VALUES ('" & Request.Form("name"
& "')", myConnection)
myConnection.Open()
myCommand.Execute()
myConnection.Close()
Response.Write("Records written to database"
End Sub JJ![[peace] [peace] [peace]](/data/assets/smilies/peace.gif)
"Ignorance and prejudice and fear walk hand in hand" - Witch Hunt, by Rush
At any rate, the error I get in the code-behind is this: 'Execute' is not a System.Data.SqlClient.SqlCommand' for the line in red.
With this in mind, what is the proper way to phrase it so the program will run and a record will be added?
I believe this example was orignally done on the Beta 1 version so that might explain why it doesn't work in .NET 1.0
Here's the whole of the code (I transfered the code for the .htm pg to .aspx, and the code for the original .aspx pg to .vb)
ASPX code:
<html>
<body>
<form method="POST">
<p>Name: <input type="text" name="name" size="20"></p>
<p><input type="submit" value="ADD" name="B1">
<input type="reset" value="RESET" name="B2"></p>
</form>
</body>
</html>
VB Code-Behind [Sean is the theoretical DB, SQLAdd is the theoretical table and NAME is the theoretical column]:
Sub Page_Load(Src as Object, E as EventArgs )
Dim myConnection as SQLConnection
myConnection = new SQLConnection("SERVER=; UID=; PWD=; DATABASE=Sean"
Dim myCommand as SQLCommand
myCommand = new SQLCommand("INSERT into SQLAdd (NAME) VALUES ('" & Request.Form("name"
myConnection.Open()
myCommand.Execute()
myConnection.Close()
Response.Write("Records written to database"
End Sub JJ
![[peace] [peace] [peace]](/data/assets/smilies/peace.gif)
"Ignorance and prejudice and fear walk hand in hand" - Witch Hunt, by Rush