Ask a Question related to ASP.NET General, Design and Development.
-
niceguy #1
Re: Getting a SQL Update syntax error...really shouldn't be?
Try putting [ ] round the password column in the UPDATE statement. I think
that SQL might be seeing that as a reserved word.
Hope it helps...
"Kathy Burke" <kathyburke40@attbi.com> wrote in message
news:uj8KKbpWDHA.1680@tk2msftngp13.phx.gbl...> Hi yet again.
>
> I have a very simple Change Password aspx. On postback the page load
> checks the password control against the database...that works fine...so
> at lease I know the connection string is working, etc.
>
> The btnSave_click event also runs, but error out on the
> Cmd.ExecuteNonQuery() command. In debug, I can see that the "very
> simple" SQL state is correct, variables there etc. The database table
> name and field names are correct. However I get a SQL UPDATE Syntax
> error in vb.net.
>
> Can anyone see something wrong?
>
> Kathy
>
> CODE***********************
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> 'Put user code to initialize the page here
>
> If IsPostBack Then
>
> Me.SetFocus(Me.txtPass)
>
> 'get password from database
> Dim varUser As String = txtUser.Text
> Dim Conn1 As New OleDbConnection()
> Dim Rdr1 As OleDbDataReader
> Dim strSQL1 As String = "SELECT Password FROM tblUsers WHERE
> ([UserName] = '" & varUser & "')"
> Dim Cmd1 As New OleDbCommand(strSQL1, Conn1)
> Conn1 = New OleDbConnection(strConn)
> Cmd1.Connection = Conn1
> Conn1.Open()
> Rdr1 = Cmd1.ExecuteReader()
> If Rdr1.Read() Then
> dbPass.Text = Rdr1("Password")
> End If
> Rdr1.Close()
> Conn1.Close()
> Else
> Me.SetFocus(Me.txtUser)
>
> End If
>
> End Sub
>
> Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btnSave.Click
>
> If Page.IsValid Then
>
> 'save new password to tblUsers
> Dim varNewPass As String = txtNewPass1.Text
> Dim varUser As String = txtUser.Text
>
> Dim Conn As OleDbConnection
> Dim Adapter As OleDbDataAdapter
> Dim Cmd As OleDbCommand
> Dim strSQL As String
>
> strSQL = "UPDATE tblUsers SET Password='" & varNewPass & "'
> WHERE UserName= '" & varUser & "'"
>
> Conn = New OleDbConnection(strConn)
> Cmd = New OleDbCommand(strSQL, Conn)
> Conn.Open()
> Cmd.ExecuteNonQuery() '******ERROR******
> Conn.Close()
>
> Response.Redirect("MainMenu.aspx")
>
> End If
> End Sub
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
niceguy Guest
-
Syntax error in UPDATE statement.
ok i have an update form that i created it is for the admin of the site to add/edit user account info for memebers to login. the form adds or edits... -
Syntax error in UPDATE query
Thanks in advance for any help... I am trying to update form data to a database from code in the action page code below.. the form is a dual purpose... -
Syntax Error Update Statement
Can someone tell me what's wrong with this code? I need help. Thanks! It is an update page. FIRST PAGE: LOGIN CHECK <!--- Filename: ... -
Syntax error in update
I'm using the update record form wizard in Dreamweaver, and am getting this error when I try to submit changes. <cfparam name='FORM.buildnumber'... -
syntax error on update
ugh, thanx for the help guess there's more than one way this syntax works as well rs("firstname")=blahblah i'm just learning sql so i tend to... -
Kathy Burke #2
Re: Getting a SQL Update syntax error...really shouldn't be?
niceguy,
That was it exactly...can't thank you enough!
Kathy
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Kathy Burke Guest



Reply With Quote

