I am getting a syntax error from my FROM SQL command in Visual Web Developer 2010. I am using the HttpContext.Current.User.Identity.Name to get the user login, checking it against an Accesss 2007 database (.mdb). I can change that SQL statement and everything
will work fine if I sly away from using the HttpContext.Current.User.Identity.Name but I want to use this. Any help?
Protected Sub Button4_Click(sender As Object, e As System.EventArgs) Handles Button4.Click
Dim ConnString As String = GetConnString()
Dim currentUserID As String = HttpContext.Current.User.Identity.Name
Dim SqlString As String = "Select FirstName From User Where SubmitedBy = ?"
Using conn As New OleDbConnection(ConnString)
Using cmd As New OleDbCommand(SqlString, conn)
cmd.CommandType = Data.CommandType.Text
cmd.Parameters.AddWithValue("SubmitedBy", currentUserID)
conn.Open()
Using reader As OleDbDataReader = cmd.ExecuteReader()
While reader.Read()
TestLabel.Text = reader("FirstName").ToString()
End While
End Using
End Using
End Using
End Sub
Lord Moldybu...
Member
4 Points
17 Posts
asp.net VB web page SQL not working
May 09, 2012 08:00 PM|LINK
I am getting a syntax error from my FROM SQL command in Visual Web Developer 2010. I am using the HttpContext.Current.User.Identity.Name to get the user login, checking it against an Accesss 2007 database (.mdb). I can change that SQL statement and everything will work fine if I sly away from using the HttpContext.Current.User.Identity.Name but I want to use this. Any help?
Protected Sub Button4_Click(sender As Object, e As System.EventArgs) Handles Button4.Click Dim ConnString As String = GetConnString() Dim currentUserID As String = HttpContext.Current.User.Identity.Name Dim SqlString As String = "Select FirstName From User Where SubmitedBy = ?" Using conn As New OleDbConnection(ConnString) Using cmd As New OleDbCommand(SqlString, conn) cmd.CommandType = Data.CommandType.Text cmd.Parameters.AddWithValue("SubmitedBy", currentUserID) conn.Open() Using reader As OleDbDataReader = cmd.ExecuteReader() While reader.Read() TestLabel.Text = reader("FirstName").ToString() End While End Using End Using End Using End Sub