这是我的代码:
Imports System.Data
Imports System.Data.SqlClient
Public Class Form2
Private conn As New SqlConnection("Data Source=wal1sql1;Initial Catalog=ValueTracker;Integrated Security=True")
Private da As New SqlDataAdapter("SELECT * FROM ValueSources", conn)
Private ds As New DataSet
Private cmb As New SqlCommandBuilder(da)
'Declaration
Public Property AllowDBNull As Boolean
Private Sub AddNullAllowedColumn()
Dim column As DataColumn
column = New DataColumn("ValueSourceID", _
System.Type.GetType("System.Int32"))
column.AllowDBNull = True
' Add the column to a new DataTable.
Dim table As DataTable
table = New DataTable
table.Columns.Add(column)
End Sub
Private Sub ValueSourcesBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles ValueSourcesBindingNavigatorSaveItem.Click
da.UpdateCommand = cmb.GetUpdateCommand
da.Update(ds.Tables("ValueSources"))
End Sub
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
da.Fill(ds, "ValueSources")
ValueSourcesDataGridView.DataSource = ds.Tables("ValueSources")
Catch
End Try
'TODO: This line of code loads data into the 'ValueTrackerDataSet.ValueSourceAvailability' table. You can move, or remove it, as needed.
Me.ValueSourceAvailabilityTableAdapter.Fill(Me.ValueTrackerDataSet.ValueSourceAvailability)
'TODO: This line of code loads data into the 'ValueTrackerDataSet.ValueSources' table. You can move, or remove it, as needed.
Me.ValueSourcesTableAdapter.Fill(Me.ValueTrackerDataSet.ValueSources)
'Me.ValueSourcesTableAdapter.GetData()
End Sub
Private Sub ServiceTypeIdTextBox_TextChanged(sender As Object, e As EventArgs)
End Sub
Private Sub BindingNavigatorAddNewItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorAddNewItem.Click
End Sub
Private Sub ValueSourcesBindingNavigator_RefreshItems(sender As Object, e As EventArgs) Handles ValueSourcesBindingNavigator.RefreshItems
End Sub
Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click
da.UpdateCommand = cmb.GetUpdateCommand
da.Update(ds.Tables("ValueSources"))
MsgBox("Successfully Saved")
End Sub
Private Sub ValueSourceIDTextBox_TextChanged(sender As Object, e As EventArgs)
End Sub
Private Sub ValueSourceNameTextBox_TextChanged(sender As Object, e As EventArgs)
da.UpdateCommand = cmb.GetUpdateCommand
da.Update(ds.Tables("valuesources"))
End Sub
Private Sub ValueSourceDescriptionTextBox_TextChanged(sender As Object, e As EventArgs)
da.UpdateCommand = cmb.GetUpdateCommand
da.Update(ds.Tables("valuesources"))
End Sub
Private Sub ServiceTypeIdTextBox_TextChanged_1(sender As Object, e As EventArgs)
da.UpdateCommand = cmb.GetUpdateCommand
da.Update(ds.Tables("valuesources"))
End Sub
Private Sub UseCaseIDTextBox_TextChanged(sender As Object, e As EventArgs)
da.UpdateCommand = cmb.GetUpdateCommand
da.Update(ds.Tables("valuesources"))
End Sub
Private Sub CreateDateDateTimePicker_ValueChanged(sender As Object, e As EventArgs)
da.UpdateCommand = cmb.GetUpdateCommand
da.Update(ds.Tables("valuesources"))
End Sub
Private Sub CreateByTextBox_TextChanged(sender As Object, e As EventArgs)
da.UpdateCommand = cmb.GetUpdateCommand
da.Update(ds.Tables("valuesources"))
End Sub
Private Sub ValueSourceDescriptionTextBox_TextChanged_1(sender As Object, e As EventArgs) Handles ValueSourceDescriptionTextBox.TextChanged
End Sub
Private Sub ValueSourceDescriptionLabel_Click(sender As Object, e As EventArgs)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Hide()
MainMenu.Show()
End Sub
End Class
我的问题是:
为什么我的数据网格可以将数据输入数据库,但我的文本框却没有?
某处断开连接,我无法弄清楚。