我正在为一个在线表单项目工作,我似乎无法找到如何从SQL数据库获取值并根据字符串验证它,在数据库= A和TextBox.text Q1 = ASQL数据库验证字符串
下面是到目前为止我的代码,但似乎无法工作,在这个有些变量是全球性的,
Dim Question As String = "Q" & count
Dim textVal As String = TextBox.Text
Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection
Dim dbSource As String = "Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\ben.miles\documents\visual studio 2012\Projects\WebTraningQuestions\WebTraningQuestions\App_Data\Usertest.mdf"
Dim ds As New DataSet
Dim sql As String = "SELECT FROM SAP"
Dim da As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(sql, conn)
conn.ConnectionString = dbSource
Dim SqSearch As String = "%" & textVal & "%"
Dim sqlQ1 As String = sql & " WHERE Questions LIKE SqSearch"
Dim cmd1 As New SqlCommand(sqlQ1, conn)
conn.Open()
'This is where I cant get my code right but if you see below. I would like it something like this.
If TextBox.Text = (database) Then
Label.Text = "Correct"
Label.ForeColor = Drawing.Color.Green
Else
Label.Text = "Wrong"
Label.ForeColor = Drawing.Color.Red
End If
这是什么(数据库)? – 2013-04-24 10:29:22
(数据库)是我不能缝编程的代码,所以我删除了它,这样有人可以更容易编程一些东西 – 2013-04-24 10:31:24