Results 1 to 16 of 16

Thread: Search db [unresolved]

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Search db [unresolved]

    How can I search my access db ? Can anyone send me a link ..?

    thanx
    Last edited by Pirate; Feb 2nd, 2003 at 11:54 PM.

  2. #2

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    *bump*

  3. #3

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I know how to Update and Add but all what I want is to search and delete !
    thanx for any help !

  4. #4
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    DELETE FROM [Table Name] WHERE [some column] = 'some value'
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  5. #5

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lord_Rat
    DELETE FROM [Table Name] WHERE [some column] = 'some value'
    thanx Lord but how can I use this ?

  6. #6

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

  7. #7

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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:
    1. Dim DelStr = "DELETE FROM [mytab] WHERE [URL]" = "'www.hotmail.com'"
    2. Dim MyCommandDEL As New OleDbCommand(DelStr, MyConnection)
    3. MyAdapter.Fill(MyDataset, "MyTab")
    4.  
    5. MyAdapter.Update(MyDataset, "MyTab")
    6. MessageBox.Show("Data Deleted...")

  8. #8

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    anyone !

  9. #9
    Addicted Member
    Join Date
    Feb 2002
    Location
    closed
    Posts
    196
    I am nowhere near VS.NET to check, but it might just be that the operation has not been commited - just a wild guess!!

  10. #10
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    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.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  11. #11

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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.
    First , Sorry for being a pain and thanx for the reply.I tried the code you offered but gives following errors :
    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()"
    VB Code:
    1. Dim myps As String = "passme"
    2. Public MyP As String = Application.StartupPath & "\webdb.mdb"
    3. Public MyConnection1 As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MyP & ";Jet OLEDB:Database Password=" & myps)
    4.  
    5. Private Sub Button2_Click(ByVal sender As System.Object _
    6. , ByVal e As System.EventArgs) Handles Button2.Click
    7.        
    8. MyConnection1.Open()
    9.  
    10. Dim DelStr = "DELETE FROM [mytab] WHERE [URL] = 'www.hotmail.com'"
    11. Dim MyCommandDEL As New OleDbCommand(DelStr, MyConnection1)
    12.  
    13. Try
    14. MyCommandDEL.ExecuteNonQuery()
    15. Catch x As Exception
    16. MsgBox(x.Message)
    17. End Try
    18. MsgBox("Done")
    19. End Sub
    Thanx for your time !

  12. #12
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    Well, here is my function:

    VB Code:
    1. Private Function ExecuteNonReader(ByVal SQLText As String) As Boolean
    2.         If Not conn.State = ConnectionState.Open Then
    3.             conn.Open() 'Global connection object
    4.         End If
    5.         Dim objCmd As New SqlClient.SqlCommand(SQLText, conn)
    6.         Try
    7.             objCmd.ExecuteNonQuery()
    8.         Catch ee As Exception
    9.             msgbox(ee.InnerException)
    10.             Return False
    11.         End Try
    12.         Return True
    13.     End Function

    When I want to run a command such as yours, I put in code:

    VB Code:
    1. ExecuteNonReader("DELETE FROM MYTABLE WHERE MYCOL='value'")

    Eventhough I am using the SQL object, the same code works for the OLEDB object.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  13. #13

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Talking Deletion problem sorted

    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

  14. #14
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    You'll need to describe search. I think an example search would help immensely.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  15. #15

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lord_Rat
    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_Rat

  16. #16

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I don't want to go back to adodb , which is the only option I can find .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width