Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

using sql statements in vb

sahabisahabi Member Posts: 1
Please how can I use sql statement in vb in order to querry my database? I m trying this for so long but unfortunately it always fails. Please and please help me. I realy rely on you.
Thanks!

Comments

  • seancampbellseancampbell Pennsylvania, USAMember Posts: 684 ✭✭✭
    first you have to know what kind of database... You have to use the correct Database Adapter package to connect to SQL Server databases as apposed to Access Databases.

    There are boat loads of tutorials online with better explanations then I could ever give... here:

    SQL Server:
    http://www.java2s.com/Code/ASP/ADO.net-Database/ReaddatafromSqlConnectionVBnet.htm

    Access:
    http://vb.net-informations.com/ado.net-dataproviders/ado.net-oledbdataAdapter.htm

    -sean
  • kingwashkingwash Member Posts: 2
    Function SearchData() As Boolean
    Dim cmd As New OracleCommand
    cmd.Connection = con.connection
    'this is the query which will select from the database
    Dim cmdQuery As String = "select *from spare_parts where item_code=" & " '" & ItemCode & "'"
    cmd.CommandText = cmdQuery
    cmd.CommandType = CommandType.Text
    Dim dataReader As OracleDataReader
    dataReader = cmd.ExecuteReader
    If dataReader.Read Then
    item_code = dataReader.Item("ITEM_CODE") 'this column name
    Item_Description = dataReader.Item("ITEM_DESCRIPTION")
    stock_name = dataReader.Item("STOCK")
    priceofitem = dataReader.Item("PRICE")
    end function


  • kingwashkingwash Member Posts: 2
    : Please how can I use sql statement in vb in order to querry my
    : database? I m trying this for so long but unfortunately it always
    : fails. Please and please help me. I realy rely on you.
    : Thanks!
    :
    Function SearchData() As Boolean
    Dim cmd As New OracleCommand
    cmd.Connection = con.connection
    'this is the query which will select from the database
    Dim cmdQuery As String = "select *from spare_parts where item_code=" & " '" & ItemCode & "'"
    cmd.CommandText = cmdQuery
    cmd.CommandType = CommandType.Text
    Dim dataReader As OracleDataReader
    dataReader = cmd.ExecuteReader
    If dataReader.Read Then
    item_code = dataReader.Item("ITEM_CODE") 'this column name
    Item_Description = dataReader.Item("ITEM_DESCRIPTION")
    stock_name = dataReader.Item("STOCK")
    priceofitem = dataReader.Item("PRICE")
    end function

    ..........................................
    i hope this work for you
    you can reach at kingwashlds@gmail.com
    telephone # +233277494317
Sign In or Register to comment.