Exception Error...why?

Results 1 to 2 of 2

Thread: Exception Error...why?

  1. #1
    Join Date
    Dec 1969

    Default Exception Error...why?

    I get the following exception error: Incorrect syntax near the keyword &#039;User&#039;<BR><BR><BR>Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click<BR><BR> &#039;*** DECLARES ***<BR> Dim myConn As SqlConnection = New SqlConnection()<BR> Dim myCommand As SqlCommand = New SqlCommand()<BR> Dim myAdapter As SqlDataAdapter = New SqlDataAdapter()<BR> Dim myDataSet As DataSet = New DataSet()<BR> Dim Row As DataRow<BR><BR> Try<BR><BR><BR> &#039;*** SETTINGS ***<BR> myConn.ConnectionString = "UID=sa;PWD=;data source=ffzj02u0;initial catalog=mdt;"<BR> myCommand.CommandText = "SELECT name, prename FROM User"<BR> myCommand.CommandType = CommandType.Text<BR> myAdapter.SelectCommand = myCommand<BR><BR> &#039;*** CALL FUNCTIONS ***<BR> myConn.Open()<BR> myCommand.Connection = myConn<BR> myAdapter.Fill(myDataSet, "User")<BR><BR> Row = myDataSet.Tables("User").Rows(0)<BR><BR> If txtPassword.Text = Row.Item("Password") Then<BR> Response.Write("login successful!")<BR> Else<BR> Response.Write("login failed")<BR> End If<BR><BR> Catch exc As Exception<BR><BR> Response.Write(exc.ToString)<BR><BR> Finally<BR><BR> myConn.Close()<BR><BR> End Try<BR><BR><BR> End Sub

  2. #2
    Join Date
    Dec 1969

    Default RE: Exception Error...why?

    something is not right in your sql.<BR><BR>you only selected the name and the prename column but you are trying to access the password column when you did <BR><BR>Row.Item("Password")<BR><BR>I also think that<BR>myAdapter.Fill(myDataSet, "User")<BR>may be wrong. Where do you define myDataSet or myAdapter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts