![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
update command
I am using ASP.NET with VB as the language.
OK, I know I'm connecting to the database properly, as things like SELECT work. But my problem is UPDATE won't work. It says it's a syntax error: Dim DateUpdated As String = Date.Now.ToString()
Dim objDateCmd As OleDbCommand = New OleDbCommand("UPDATE teacher_info SET date='" & DateUpdated & "' WHERE username='" & User & "'", objConn)Anyone have any ideas why this is happening? Thanks.
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
hmm, looks alright from what I can see, can you post the entire code pertaining to the DB?
also, can you put the exact error message you get and at what line it occurs?
__________________
I have never let my schooling interfere with my education. -Mark Twain- Xbox live gamertag: melbolt |
|
|
|
|
|
#3 | ||
|
Hobbyist Programmer
|
error message:
Quote:
Quote:
Dim objConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DBPath) + ";Jet OLEDB:Database Locking Mode=3")
objConn.Open()
Dim User As String
User = Session.Item("User") ' yes believe me this is set, it works in other places
'Dim objCmd As New OleDbCommand("UPDATE teacher_info SET bulliten='" & Me.txtBulliten.Text & "' WHERE username='" & Session.Item("Username") & "'", objConn)
Dim objCmd As New OleDbCommand("UPDATE teacher_info SET bulliten='" & Bulliten & "' WHERE username='" & User & "'", objConn)
Dim objDataReader As OleDbDataReader = objCmd.ExecuteReader()
Dim DateUpdated As String = Date.Now.ToString()
Dim objDateCmd As OleDbCommand = New OleDbCommand("UPDATE teacher_info SET date='" & DateUpdated & "' WHERE username='" & User & "'", objConn)
Dim objDataDateReader As OleDbDataReader = objDateCmd.ExecuteReader()stack trace: [OleDbException (0x80040e14): Syntax error in UPDATE statement.] System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +65 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +181 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +307 System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +77 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +188 System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +123 System.Data.OleDb.OleDbCommand.ExecuteReader() +26 bulliten.cmdSubmitBulliten_Click(Object sender, EventArgs e) in C:\Documents and Settings\Intimidat0r\My Documents\Visual Studio 2005\WebSites\Sierra\controlpanel.aspx.vb:68 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +116 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3840
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
||
|
|
|
|
|
#4 |
|
Expert Programmer
|
Just being pedantic, but for your date to be a valid SQL date on all locales, you should use:
(New System.data.SqlTypes.SqlDateTime(System.DateTime.Now())).ToSqlString I think the error might be that the field name, `date` isn't in quotes, as it's a reserved SQL keyword. Also bulletin is misspelled :p. EDIT: What's up with the code tag tabbing? |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
|
yes that was it, the quotes thing. thanks.
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|