How can I search my access db ? Can anyone send me a link ..?
thanx
Printable View
How can I search my access db ? Can anyone send me a link ..?
thanx
*bump*
I know how to Update and Add but all what I want is to search and delete !:rolleyes:
thanx for any help !
DELETE FROM [Table Name] WHERE [some column] = 'some value'
thanx Lord but how can I use this ?Quote:
Originally posted by Lord_Rat
DELETE FROM [Table Name] WHERE [some column] = 'some value'
:(
so far , I've this code to delete a record .I got everything correct and msgbox shown that the record has been deleted but when I check the source it's still there (it's not updating).so what am I doing wrong here ?
VB Code:
Dim DelStr = "DELETE FROM [mytab] WHERE [URL]" = "'www.hotmail.com'" Dim MyCommandDEL As New OleDbCommand(DelStr, MyConnection) MyAdapter.Fill(MyDataset, "MyTab") MyAdapter.Update(MyDataset, "MyTab") MessageBox.Show("Data Deleted...")
anyone !:(
I am nowhere near VS.NET to check, but it might just be that the operation has not been commited - just a wild guess!!
Dim DelStr = "DELETE FROM [mytab] WHERE [URL] = 'www.hotmail.com'"
Dim MyCommandDEL As New OleDbCommand(DelStr, MyConnection)
MyCommandDEL.ExecuteNonQuery()
msgbox("Done")
See my changes in bold.
First , Sorry for being a pain and thanx for the reply.I tried the code you offered but gives following errors :Quote:
Originally posted by Lord_Rat
Dim DelStr = "DELETE FROM [mytab] WHERE [URL] = 'www.hotmail.com'"
Dim MyCommandDEL As New OleDbCommand(DelStr, MyConnection)
MyCommandDEL.ExecuteNonQuery()
msgbox("Done")
See my changes in bold.
an unhandled exception of type 'system.data.oledb.oledbexception' occurred in system.data.dll
no value given for one or more required parameters.
in line "MyCommandDEL.ExecuteNonQuery()"
Thanx for your time !VB Code:
Dim myps As String = "passme" Public MyP As String = Application.StartupPath & "\webdb.mdb" Public MyConnection1 As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MyP & ";Jet OLEDB:Database Password=" & myps) Private Sub Button2_Click(ByVal sender As System.Object _ , ByVal e As System.EventArgs) Handles Button2.Click MyConnection1.Open() Dim DelStr = "DELETE FROM [mytab] WHERE [URL] = 'www.hotmail.com'" Dim MyCommandDEL As New OleDbCommand(DelStr, MyConnection1) Try MyCommandDEL.ExecuteNonQuery() Catch x As Exception MsgBox(x.Message) End Try MsgBox("Done") End Sub
Well, here is my function:
VB Code:
Private Function ExecuteNonReader(ByVal SQLText As String) As Boolean If Not conn.State = ConnectionState.Open Then conn.Open() 'Global connection object End If Dim objCmd As New SqlClient.SqlCommand(SQLText, conn) Try objCmd.ExecuteNonQuery() Catch ee As Exception msgbox(ee.InnerException) Return False End Try Return True End Function
When I want to run a command such as yours, I put in code:
VB Code:
ExecuteNonReader("DELETE FROM MYTABLE WHERE MYCOL='value'")
Eventhough I am using the SQL object, the same code works for the OLEDB object.
What a cute Function !
a million thanx Lord_Rat .
I'd to change sqlclient to oledb .easy job .
What left now is search issue .any idea ?
thanx again
You'll need to describe search. I think an example search would help immensely.
I'don't have any search example:( .only (vb6 code if you want have a look at it !!).thanx Lord_RatQuote:
Originally posted by Lord_Rat
You'll need to describe search. I think an example search would help immensely.
I don't want to go back to adodb :( , which is the only option I can find .