G
Guest
I have following code, but I do not know where the problem is. Thank you for
any help.
David
----Code---
'connection
conn = New SqlConnection _
("data source=localhost;integrated security=true;initial
catalog=DemoCRQdatabase")
'command
Dim propertyCMD As New SqlCommand("INERT INTO " &
txtProperty.Text & "(Code, Name) VALUES(" & txtCode.Text & ", " &
txtName.Text & ")", conn)
'command type: CommandType.Text
propertyCMD.CommandType = CommandType.Text
'Open connection and execute the insert statement
conn.Open()
propertyCMD.ExecuteNonQuery()
conn.Close()
----
----error message-----
Incorrect syntax near the keyword 'INTO'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near
the keyword 'INTO'.
Source Error:
Line 66: propertyCMD.CommandType = CommandType.Text
Line 67: 'Open connection and execute the insert statement
Line 68: conn.Open()
Line 69: propertyCMD.ExecuteNonQuery()
Line 70: conn.Close()
Source File: c:\inetpub\wwwroot\Demo\AddClassProperty.aspx.vb Line: 68
any help.
David
----Code---
'connection
conn = New SqlConnection _
("data source=localhost;integrated security=true;initial
catalog=DemoCRQdatabase")
'command
Dim propertyCMD As New SqlCommand("INERT INTO " &
txtProperty.Text & "(Code, Name) VALUES(" & txtCode.Text & ", " &
txtName.Text & ")", conn)
'command type: CommandType.Text
propertyCMD.CommandType = CommandType.Text
'Open connection and execute the insert statement
conn.Open()
propertyCMD.ExecuteNonQuery()
conn.Close()
----
----error message-----
Incorrect syntax near the keyword 'INTO'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near
the keyword 'INTO'.
Source Error:
Line 66: propertyCMD.CommandType = CommandType.Text
Line 67: 'Open connection and execute the insert statement
Line 68: conn.Open()
Line 69: propertyCMD.ExecuteNonQuery()
Line 70: conn.Close()
Source File: c:\inetpub\wwwroot\Demo\AddClassProperty.aspx.vb Line: 68