■58920 / ) |
Re[2]: データベース更新 |
□投稿者/ jrk (2回)-(2011/05/04(Wed) 14:40:17)
|
接続はできています。 登録処理はできますので。
以下のようにしてみたのですが、またDBの更新ができません。 どこがおかしいのでしょうか。
''' ------------------------------------- ''' ''' 削除ボタンの処理 ''' ''' -------------------------------------- Private Sub sakuzyo_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sakuzyo_btn.Click
''Me.DataGridView.Rows.RemoveAt(Me.DataGridView.CurrentCell.RowIndex)
Dim connStr As String = "Data Source = OWNER-PC\SQLEXPRESS; Initial Catalog = kakeibo; Integrated Security = True"
Dim sql As String = "SELECT * FROM Table_1" Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection(connStr)
Dim comm As SqlClient.SqlCommand = New SqlClient.SqlCommand(sql, conn) Dim dataadapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(comm)
Dim ds As DataSet = New DataSet()
conn.Open() dataadapter.Fill(ds, "Table_1") conn.Close() DataGridView.DataSource = ds DataGridView.DataMember = "Table_1"
Dim sqlCmdBuilder As New SqlClient.SqlCommandBuilder(dataadapter) sqlCmdBuilder.GetUpdateCommand() dataadapter.Update(ds.Tables("Table_1"))
End Sub
|
|