我有一个用于在数据库中保存事务的Web表单和一个显示上一个操作的按钮,但它没有工作,尽管没有错误消息。
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim nmb As Long = Convert.ToInt32(TextBox1.Text) - 1
Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("dataConnectionString").ConnectionString)
Dim sql1 As New SqlCommand("select * from internal_trans where numbr = @numbr", conn)
sql1.Parameters.AddWithValue("@numbr", nmb)
conn.Open()
Dim adapter As New SqlDataAdapter
Dim ds As New DataSet
adapter.SelectCommand = sql1
adapter.Fill(ds)
Me.TextBox1.Text = ds.Tables(0).Rows(0).Item(0).ToString
Me.TextBox2.Text = ds.Tables(0).Rows(0).Item(1).ToString
adapter.Dispose()
sql1.Dispose()
conn.Close()
End Sub