![]() |
| ||
| deleting the records of the MS access table using VB.NET I have to delete the records in a ms access table using vb.net when i click on a button. |
| ||
| Re: deleting the records of the MS access table using VB.NET Dim con as new OledbConnection con = new OledbConnection (constring) con.open() Dim cmd as new OledbCommand cmd = new OledbCommand("Delete Query") cmd.ExecuteNonQuery() cmd.Dispose() con.close() |
| ||
| Re: deleting the records of the MS access table using VB.NET I tried this code and it is throwing an exception that connection property has not been initialized!!! giving error in this statement cmd.ExecuteNonQuery() |
| ||
| Re: deleting the records of the MS access table using VB.NET Hi, pls post your code |
| ||
| Re: deleting the records of the MS access table using VB.NET try this Dim con as new OledbConnection con = new OledbConnection (constring) con.open() Dim cmd as new OledbCommand cmd = new OledbCommand("Delete Query",con) cmd.ExecuteNonQuery() cmd.Dispose() con.close() |
| ||
| Re: deleting the records of the MS access table using VB.NET Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Try oCmdOleDb = New OleDbCommand("Delete from table1") oConnOleDb = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\database1.mdb") oConnOleDb.Open() If (oCmdOleDb.ExecuteNonQuery > 0) Then StatusStrip1.Items(0).Text = ("records deleted from the table") End If Catch ex As Exception MsgBox(ex.Message.ToString(), MsgBoxStyle.Information) Finally oConnOleDb.Close() End Try End Sub [/code] |
| ||
| Re: deleting the records of the MS access table using VB.NET Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Try oConnOleDb = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\database1.mdb") oConnOleDb.Open() oCmdOleDb = New OleDbCommand("Delete from table1",oConnOleDb) If (oCmdOleDb.ExecuteNonQuery > 0) Then StatusStrip1.Items(0).Text = ("records deleted from the table") End If Catch ex As Exception MsgBox(ex.Message.ToString(), MsgBoxStyle.Information) Finally oConnOleDb.Close() End Try End Sub |
| ||
| Re: deleting the records of the MS access table using VB.NET Thanks a ton...I solved the problem |
| All times are GMT -4. The time now is 9:00 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC