About SQL

Hello to all expert there,
need a help can anybody know how to search on a SQL using Visual
Basic application that can search a metaname in a different table
and show record and can link to that record just like a search
engine in google.
Thanks and i know you can help thanks and more power


-HaKuMeTa-
-=-

Comments

  • [b][red]This message was edited by doofusboy at 2005-9-21 5:51:41[/red][/b][hr]
    : Hello to all expert there,
    : need a help can anybody know how to search on a SQL using Visual
    : Basic application that can search a metaname in a different table
    : and show record and can link to that record just like a search
    : engine in google.
    : Thanks and i know you can help thanks and more power
    :
    :
    : -HaKuMeTa-
    : -=-
    :
    Just use ADO to connect to the database and execute SQL queries against the database like the following example:

    Private Sub Command1_Click()
    Dim cn As ADODB.connection
    Dim rs As ADODB.Recordset
    Dim sql As String
    Dim connstr As String

    connstr = "provider=microsoft.jet.oledb.4.0;data source=h:TestExcelDB.xls;extended properties=Excel 8.0;"

    Set cn = New ADODB.connection
    cn.open connstr

    sql = "select * from [Sheet1$]" 'specify where condition here
    Set rs = New ADODB.Recordset

    Set rs = cn.execute(sql)
    rs.MoveFirst
    Text1.Text = rs.Fields(0)
    Text2.Text = rs.Fields(1)
    Text3.Text = rs.Fields(2)
    End Sub

    This example queries the fields in an Excel 'database', your connection string will depend upon the type of database you want to access [Oracle, SQLServer, DB2, etc.] and, obviously, your SQL string will depend on the column names and table name(s) of the database you are connecting to.

    This should get you started, post back if you have questions.



  • Thanks for the info but what i want to be happen is to look a record in any table with the same field name in a database. i wish you could help me more needed badly!!
    -HaKuMeTa-
    -=-

  • [b][red]This message was edited by lionb at 2005-9-21 12:36:10[/red][/b][hr]
    : Thanks for the info but what i want to be happen is to look a record in any table with the same field name in a database. i wish you could help me more needed badly!!
    : -HaKuMeTa-
    : -=-
    :
    :
    Take a look at following link. There is some information hoq to search databse for partikular record using information schema. Goog luck!
    http://vyaskn.tripod.com/sql_server_search_and_replace.htm


  • [b][red]This message was edited by jamesooooo at 2005-9-21 18:34:13[/red][/b][hr]
    : Hello to all expert there,
    : need a help can anybody know how to search on a SQL using Visual
    : Basic application that can search a metaname in a different table
    : and show record and can link to that record just like a search
    : engine in google.
    : Thanks and i know you can help thanks and more power
    :
    :
    : -HaKuMeTa-
    : -=-
    :
    Are you looking to know how to use SQl to do a query against a table in a database and get the results in a recordset that you can view? if so do the following :


    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Set cn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    cn.connectionstring = connectionstring '"Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source= c:databasename.mdb"
    cn.Open
    rs.Open "SELECT * from yourtable where field1 = fu", cn, adOpenKeyset, adLockPessimistic, adCmdText

    that will return all records in database table yourtable with field1 that has the value of fu.

    then you could display the recordeset or move around in it like this:

    rs.movefirst ' moves to first record in recordset
    rs.movenext ' moves to next record in recordset
    rs.moveprevious ' moves back one record
    rs.movelast ' moves to last record

    then you could display the fields you want from the chosen record like this

    create a textbox called say.. text1

    text1 = rs.fields("field1")

    I hope that is waht you needed. If you need to be able to take a person's input from a text box and get the results then you could use
    the LIKE operator. which you whould do soemthing like this for a query:

    rs.Open "SELECT * from yourtable where field1 like %fu%", cn, adOpenKeyset, adLockPessimistic, adCmdText

    that would return and tables with field1 containing fu in any part of the string. % is a wildcard
    oh, that is using an access database as the backend.
    James


Sign In or Register to comment.

Howdy, Stranger!

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

Categories