sahra_777
چهارشنبه 16 فروردین 1385, 11:29 صبح
با سلام...من میخوام اطلاغاتی که در دیتاگرید تغییر میدم در دیتابیس ذخیره بشه اگه میشه کدش رو بهم بدید در ضمن از کانکشن ویزارد هم استفاده نمیکنم لطفا راهنمایی کنید
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.Open()
dap = New SqlDataAdapter(Str, con)
dap.Fill(ds, "repair_tel")
GridEX1.DataSource = ds.Tables("repair_tel")
end sub
Private Sub Button2_Click(.................................... .) Handles Button2.Click
Dim changedRecords As System.Data.DataTable = ds.Tables("repair_tel").GetChanges()
If Not (changedRecords Is Nothing) AndAlso (changedRecords.Rows.Count > 0) Then
If MessageBox.Show(String.Format("You are about to update {0} record(s)." + vbCrLf + "Do you want to continue?", changedRecords.Rows.Count), "GridEX Tutorial", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
Try
dap.Update(ds, "repair_tel")
Catch exc As Exception
MessageBox.Show("An error occurred while trying to update the database:" + vbCrLf + vbCrLf + vbCrLf + "The rows with errors will appear in dark red.", "GridEX Tutorial", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
Else
MessageBox.Show("There are no changes in the Products table to update.", "GridEX Tutorial", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If
End Sub
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.Open()
dap = New SqlDataAdapter(Str, con)
dap.Fill(ds, "repair_tel")
GridEX1.DataSource = ds.Tables("repair_tel")
end sub
Private Sub Button2_Click(.................................... .) Handles Button2.Click
Dim changedRecords As System.Data.DataTable = ds.Tables("repair_tel").GetChanges()
If Not (changedRecords Is Nothing) AndAlso (changedRecords.Rows.Count > 0) Then
If MessageBox.Show(String.Format("You are about to update {0} record(s)." + vbCrLf + "Do you want to continue?", changedRecords.Rows.Count), "GridEX Tutorial", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
Try
dap.Update(ds, "repair_tel")
Catch exc As Exception
MessageBox.Show("An error occurred while trying to update the database:" + vbCrLf + vbCrLf + vbCrLf + "The rows with errors will appear in dark red.", "GridEX Tutorial", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
Else
MessageBox.Show("There are no changes in the Products table to update.", "GridEX Tutorial", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If
End Sub