Sql 指定的强制转换不可用
有人能帮我查一下这个密码吗 is表示指定的强制转换不可用Sql 指定的强制转换不可用,sql,sql-server,vb.net,Sql,Sql Server,Vb.net,有人能帮我查一下这个密码吗 is表示指定的强制转换不可用 MysqlConn = New SqlConnection MysqlConn.ConnectionString = "Data Source=SABAHALI-SHEIKH;Initial Catalog=md_1103763;Integrated Security=True" Dim READER As SqlDataReader Try MysqlConn.Open()
MysqlConn = New SqlConnection
MysqlConn.ConnectionString =
"Data Source=SABAHALI-SHEIKH;Initial Catalog=md_1103763;Integrated Security=True"
Dim READER As SqlDataReader
Try
MysqlConn.Open()
Dim Query As String
Query = "SELECT [firstname] FROM md_1103763.dbo.customer where firstname='" & ComboBox1.Text & "'"
COMMAND = New SqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader
While READER.Read
TextBox1.Text = READER.GetInt32("customerID")
TextBox2.Text = READER.GetString("firstname")
TextBox3.Text = READER.GetString("surname")
TextBox4.Text = READER.GetString("contactnumber")
TextBox5.Text = READER.GetString("emailaddress")
End While
MysqlConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
必须选择表中的所有列 及
您的代码中有很多问题。
READER.Item(“customerID”).ToString
我更改了它,但有一个错误,它说从字符串到整型的转换无效。您可以在此代码上帮助我吗?单击它将带您到我的问题页面的链接您可以帮我吗
Try
MysqlConn.Open()
Dim Query As String = Nothing
Query = "SELECT * FROM md_1103763.dbo.customer where firstname='" + ComboBox1.Text & "'"
COMMAND() = New SqlCommand(Query, MysqlConn)
READER = COMMAND().ExecuteReader
While READER.Read
TextBox1.Text = READER("customerID").ToString()
TextBox2.Text = READER("firstname").ToString()
TextBox3.Text = READER("surname").ToString()
TextBox4.Text = READER("contactnumber").ToString()
TextBox5.Text = READER("emailaddress").ToString()
End While
MysqlConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
MysqlConn = New SqlConnection
MysqlConn.ConnectionString =
"Data Source=SABAHALI-SHEIKH;Initial Catalog=md_1103763;Integrated Security=True"
Dim READER As SqlDataReader
Try
MysqlConn.Open()
Dim Query As String
Query = "SELECT [customerID], [firstname], [surname], [contactnumber], [emailaddress] FROM md_1103763.dbo.customer where firstname='" & ComboBox1.Text & "'"
COMMAND = New SqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader
While READER.Read
TextBox1.Text = READER.GetInt32(READER.GetOrdinal("customerID"))
TextBox2.Text = READER.GetString(READER.GetOrdinal("firstname"))
TextBox3.Text = READER.GetString(READER.GetOrdinal("surname"))
TextBox4.Text = READER.GetString(READER.GetOrdinal("contactnumber"))
TextBox5.Text = READER.GetString(READER.GetOrdinal("emailaddress"))
End While
MysqlConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try