well i got an aspx page that supposed to insert some data in sql server db and it generates this sql statment but it give error in writing to sql server 2000:
Server Error in '/asp' Application.
--------------------------------------------------------------------------------
The name 'me' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.
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: The name 'me' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.
Note: me is the value for name feild that i typed in the form
I be happy if some one help me how to correct it. Thanks
Here is the corde part that supposed to generate the insert statment :
<%@ Page Language="
VB" %>
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.SQLClient" %>
<script Language="
VB" Option="Explicit" runat="server">
Sub Page_Load(Src as object, E as EventArgs)
' Hide Insert Confirmation Message
pnlConfirm.Visible = False
End Sub
Sub btnSave_OnClick(Src as object, E as EventArgs)
Dim dtDateTimeInput as DateTime
Dim strSQL as String
Dim objConnection as SqlConnection
Dim objCommand as SqlCommand
If Page.IsValid Then
' Save the Data to the DB
' Check Values - The validators do most of this, but I was
' too lazy to come up with (ie. write) a custom validator for
' the Date/Time field.
Try
validtxtDateTimeField.Text = ""
dtDateTimeInput = CDate(txtDateTimeField.Text)
Catch Exp As Exception
'Response.Write(Exp)
validtxtDateTimeField.Text = "Please enter a valid Date/Time value."
Exit Sub
End Try
' Build our SQL String
strSQL = ""
strSQL = strSQL & "INSERT INTO PLAYERS "
strSQL = strSQL & "(PLAYERNO,NAME,INIIALS,BIRTH_DATE,************,JOINED,STRE E T,HOUSENO,POSTCODE,TOWN,PHONENO,LEAGUENO) " & vbCrLf
strSQL = strSQL & "VALUES ("
strSQL = strSQL & "'" & txtIntegerField1.Text & "'"
strSQL = strSQL & ", "
strSQL = strSQL & txtTextField1.Text
strSQL = strSQL & ", "
strSQL = strSQL & "'" & txtTextField2.Text & "'"
strSQL = strSQL & ", "
strSQL = strSQL & txtDateTimeField.Text
strSQL = strSQL & ", "
strSQL = strSQL & "'" & txtTextField3.Text & "'"
strSQL = strSQL & ", "
strSQL = strSQL & txtIntegerField2.Text
strSQL = strSQL & ", "
strSQL = strSQL & "'" & txtTextField4.Text & "'"
strSQL = strSQL & ", "
strSQL = strSQL & txtIntegerField3.Text
strSQL = strSQL & ", "
strSQL = strSQL & "'" & txtIntegerField4.Text & "'"
strSQL = strSQL & ", "
strSQL = strSQL & txtTextField5.Text
strSQL = strSQL & ", "
strSQL = strSQL & "'" & txtIntegerField5.Text & "'"
strSQL = strSQL & ", "
strSQL = strSQL & txtIntegerField6.Text
'strSQL = strSQL & ", "
'strSQL = strSQL & "'" & dtDateTimeInput & "'"
strSQL = strSQL & ");"
Response.Write(strSQL)
' Set up our connection.
objConnection = New SqlConnection("Data Source=(local);" _
& "Initial Catalog=teniss2;User Id=web;Password=web;" _
& "Connect Timeout=15;Network Library=dbmssocn;")
objCommand = New SqlCommand(strSQL, objConnection)
objCommand.Connection.Open()
objCommand.ExecuteNonQuery()
objCommand.Connection.Close()
' Display Confirmation Message:
lblSQL.Text = strSQL
pnlConfirm.Visible = True
End If
End Sub
</script>