Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 11th, 2010, 09:14 PM
Registered User
 
Join Date: Jan 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
 
Old January 18th, 2010, 11:36 AM
Registered User
 
Join Date: Jan 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question syntex error in INSERT INTO statment

As you have not stated this, I wonder if you have walked this thru in your debugger to check the input values as it seems at first blush that this might be the cause of your syntax error you are getting a NULL value for one of your input values. That is something I have experienced in the past that caused similar error as you describe here.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to drop the first 4 digits from an insert statment bex BOOK: Expert SQL Server 2005 Integration Services ISBN: 978-0-470-13411-5 0 August 28th, 2009 04:24 AM
problem with this insert statment in vba method Access VBA 1 June 22nd, 2005 12:26 PM
PROBLEM WITH INSERT STATMENT sanjeet General .NET 1 February 4th, 2005 09:39 AM
error '80040e14' Syntex error in From clause alisonchase Access ASP 5 January 2nd, 2005 10:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.