hello frnds this is my code i m having problem while updating my database... In this code when i delete records then it will deleted but it can't show updated data..for viewing new updated data i hav to again open the form ... so is there any code which i miss??? to update database @ runtime??
Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\SmS Application\New.mdb") Dim cmd As New OleDbCommand Dim ds As New DataSet Dim DataSet1 As New DataSet Dim cmdOLEDB As New OleDbCommand Dim cmdInsert As New OleDbCommand Dim cmdUpdate As New OleDbCommand Dim cmdDelete As New OleDbCommand Dim delete As New OleDb.OleDbCommand("delete INTO Table2 (PhoneNumber,Message,Dates) VALUES (@PhoneNumber,@Message, now())", con) Dim adapter As New OleDb.OleDbDataAdapter("SELECT PhoneNumber, Message FROM Table2", con) con.Open() cmdDelete.CommandType = CommandType.Text cmdDelete.Connection = con If (MessageBox.Show("Are u sure want to delete ehere id = " & TextBox1.Text, "", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) = Windows.Forms.DialogResult.Yes Then cmdDelete.CommandText = "DELETE FROM Table2 WHERE ID = " & TextBox1.Text cmdDelete.ExecuteNonQuery() MessageBox.Show(" Records Deleted!! ") Else End If Exit Sub cmdDelete.Dispose() adapter.Update(DataSet1, "table2") con.Close() End Sub




Reply With Quote
