VB Data问题

来源:百度知道 编辑:UC知道 时间:2024/06/24 18:28:16
怎么样保存DataGridView
比如DataView里面输入了顾客的电话 需要保存 以便之后打开时候继续使用查看或是在另外项目中打开继续使用查看

那么,怎么样绑定到数据库呢? 代码?名称? 写具体 问题成功解决 还加分
我目前的代码是
Public Class Form2

Private Sub CustomerIDToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomerIDToolStripMenuItem.Click
DataGridView1.Show()
DataGridView2.Visible = False
End Sub

Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click

DataGridView1.Refresh()
DataGridView1.Update()
End Sub

Private Sub FirstNameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FirstNameToolStripMenuItem.Click
DataGridView2.Show()
DataGridView1.Visible = False
End Sub

Private Sub ResetToolStripMenuItem_Click(ByVal sender As Syste

Private Sub GetData(ByVal selectCommand As String)

Try
Dim connectionString As String = _
"Integrated Security=SSPI;Persist Security Info=False;" + _
"Initial Catalog=Northwind;Data Source=localhost"

Me.dataAdapter = New SqlDataAdapter(selectCommand, connectionString)

Dim commandBuilder As New SqlCommandBuilder(Me.dataAdapter)

Dim table As New DataTable()
table.Locale = System.Globalization.CultureInfo.InvariantCulture
Me.dataAdapter.Fill(table)
Me.DataGridView1.DataSource = table

Me.DataGridView1.AutoResizeColumns( _
DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader)
Catch ex As SqlException
MessageBox.Show("To run this example, replace the value of the " + _
"connectionString variable with a connection string that