Imports System.Data.SqlClient
Imports System.Data
Public Class Window1
Private Sub btn_Click(sender As Object, e As RoutedEventArgs) Handles btn.Click
Dim cmd As SqlCommand = New SqlCommand("SELECT * from tencmpC1 where qnumber='1';", New SqlConnection("Server=(localdb)\Projects;Database=master;Uid=sa;Pwd=12345;"))
Try
cmd.Connection.Open()
Dim adp As New SqlDataAdapter(cmd)
Dim dt As New DataTable()
adp.Fill(dt)
txt1.Text = dt.Rows(0)("qnumber").ToString()
txt2.Text = dt.Rows(0)("topic").ToString()
txt3.Text = dt.Rows(0)("Umcq").ToString()
txt4.Text = dt.Rows(0)("Usq").ToString()
txt5.Text = dt.Rows(0)("Ulq").ToString()
txt6.Text = dt.Rows(0)("Emcq").ToString()
txt7.Text = dt.Rows(0)("Esq").ToString()
txt8.Text = dt.Rows(0)("Elq").ToString()
txt9.Text = dt.Rows(0)("Pdate").ToString()
cmd.ExecuteNonQuery()
Catch ex As Exception
txt10.Text = ex.Message
End Try
End Sub
End Class
以上代码来自vb文件。我有WPF表格。我做错了什么,请指导我?