我收到错误“查询表达式'用户名=用户'中的字符串语法错误我认为问题出在“me.Username.tag”但我卡住了。
conn = New OleDbConnection(Get_Constring)
conn.Open()
cmd.Connection = conn
cmd.CommandType = CommandType.Text
cmd.CommandText = "select Username, fname, lname, mname, [password], [level], Question, answer from Instructor where Username= '" & Me.txtusername.Tag
dr = cmd.ExecuteReader
If dr.HasRows Then
While dr.Read
Me.txtusername.Tag = dr("Username")
Me.txtfname.Text = IIf(Not IsDBNull(dr("fname")), dr("fname"), "")
Me.txtlname.Text = IIf(Not IsDBNull(dr("lname")), dr("lname"), "")
Me.txtinitial.Text = IIf(Not IsDBNull(dr("mname")), dr("mname"), "")
Me.txtpassword.Text = IIf(Not IsDBNull(dr("password")), dr("password"), "")
Me.lbllevel.Text = IIf(Not IsDBNull(dr("level")), dr("level"), "")
Me.txtusername.Text = IIf(Not IsDBNull(dr("Username")), dr("Username"), "")
Me.cmbquestion.Text = IIf(Not IsDBNull(dr("Question")), dr("Question"), "")
Me.txtanswer.Text = IIf(Not IsDBNull(dr("answer")), dr("answer"), "")
End While
End If