syntex error in INSERT INTO statment
שגיאת תחביר במשפט INSERT INTO.
תיאור: חריג שאינו מטופל התרחש במהלך ביצוע בקשת האינטרנט הנוכחית. אנא עיין ברכיב המעקב אחר מחסנית לקבלת מידע נוסף אודות השגיאה והיכן מקורה בקוד.
פרטי חריג: System.Data.OleDb.OleDbException: syntex error in INSERT INTO statment.
שגיאת מקור:
שורה 38: myCommand.Connection = myConnection שורה 39: myConnection.Open() שורה 40: myCommand.ExecuteNonQuery() שורה 41: myCommand.Connection.Close() שורה 42: Response.Write(myInsertQuery)
קובץ מקור: c:\inetpub\wwwroot\HIVCentral\newActivist.aspx שורה: 40
רכיב מעקב אחר מחסנית:
[OleDbException (0x80040e14): שגיאת תחביר במשפט INSERT INTO.] System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(OleDbHResult hr) +1003520 System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult) +255 System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) +188 System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult) +58 System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method) +161 System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +113 ASP.hivcentral_newactivist_aspx.addActivist(Object obj, EventArgs e) in c:\inetpub\wwwroot\HIVCentral\newActivist.aspx:40 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111 System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +110 System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
my code is this:
please notice that on the first time i am doing the insert it is ok but the second insert is the problem
sub addActivist(obj as Object, e as EventArgs)
Dim myConnection As New OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source=c:\games\activistsDB.mdb")
Dim myInsertQuery As String = "INSERT INTO activists (ID, firstName, LastName, ************, bDate, city, street," & _
"stNumber, appNumber, apploiment, notes, status) " & _
"VALUES ('" & id.text & "', '" & firstName.text & "', '" & lastName.text & "', '" & sexC.SelectedItem.value & "', '" & _
bDate.text & "', '" & city.text & "', '" & street.text & "', '" & stNumber.text & "', '" & appNumber.text & "', '" & _
apploiment.text & "', '" & notes.text & "', 'new')"
Dim myCommand As New OleDbCommand(myInsertQuery)
myCommand.Connection = myConnection
myConnection.Open()
myCommand.ExecuteNonQuery()
myCommand.Connection.Close()
Response.Write(myInsertQuery)
'tokenize the fields
dim phoneArr as String = StrTok(phone.text, ",")
dim celArr as String = StrTok(cel.text, ",")
dim eMailArr as String = StrTok(eMail.text, ",")
dim specialtiesArr as String = StrTok(specialty.text, ",")
'insert contacts data
Do While phoneArr <> ""
myInsertQuery = "INSERT INTO (ID, type, connection) VALUES ('" & id.text & "', 'phone', '" & phoneArr & "')"
myCommand = New OleDbCommand(myInsertQuery)
myCommand.Connection = myConnection
myConnection.Open()
myCommand.ExecuteNonQuery()
myCommand.Connection.Close()
Response.Write(myInsertQuery)
phoneArr = StrTok(, ",")
Loop
result.text="הנתונים התווספו למערכת "
end sub
sub clearD(obj as Object, e as eventargs)
bDate.text=""
firstName.text=""
lastName.text=""
id.text=""
end sub
sub sexValidator(obj as object, e as ServerValidateEventArgs)
if sexC.SelectedIndex=0 OR sexC.SelectedIndex=1 then
e.isValid=true
else
e.isValid=false
end if
end sub
function StrTok( _
Optional ByVal ScanString As String = "", _
Optional ByVal Token As String = "", _
Optional ByVal SyncTok As Boolean = False, _
Optional ByVal SkipQuotes As Boolean = False, _
Optional ByVal QuoteChar As String = Chr(34), _
Optional ByVal EscapeChar As String = "\") _
As String
Static Stored As String
Dim i As Long, _
l As Long, _
vCh As String, _
OutStr As String, _
sLen As Long
Dim inQ As Boolean, _
skipQ As Boolean, _
qChar As String, _
eChar As String
On Error Resume Next
If (QuoteChar = "") Then qChar = Chr(34) _
Else qChar = QuoteChar
If (SyncTok = True) Then
If (ScanString = "") Then
StrTok = Stored
Else
Stored = ScanString
End If
Exit Function
End If
If (Token = "") Then Exit Function
If ScanString <> vbNullString Then
Stored = ScanString
End If
If Stored = vbNullString Then Exit Function
If (Stored.Length >= Token.Length) Then
If Stored.Substring(0, Token.Length - 1) = Token Then
Stored = Stored.Substring(Token.Length - 1)
StrTok = ""
Exit Function
End If
End If
skipQ = SkipQuotes
sLen = Stored.Length - 1
For i = 0 To sLen
vCh = Stored.Substring(i, Len(Token))
If (vCh = Token) And ((inQ = False) _
Or (skipQ = False)) Then
If ((i + Len(Token)) <= sLen) Then
StrTok = OutStr
Stored = Stored.Substring(i + Len(Token))
Exit Function
Else
Exit For
End If
Else
vCh = Stored.Substring(i, 1)
OutStr += vCh
If (vCh = qChar) And (skipQ = True) Then
inQ = (Not inQ)
If (i > 0) Then
vCh = Stored.Substring(i - 1, 1)
If (vCh = eChar) Then
inQ = (Not inQ)
End If
End If
End If
End If
Next i
StrTok = OutStr
Stored = vbNullString
End Function
strTok is simply a tokenizer the problem is on the looped insert!
i also checked the insert string a couple of times with many different inputs and it checks out
INSERT INTO (ID, type, connection) VALUES ('546765', 'phone', '0544920896')
INSERT INTO (ID, type, connection) VALUES ('546765', 'phone', '0544920896')
what ever help u can give would be highly appriciated
|