Results 1 to 3 of 3

Thread: SQL Statements

  1. #1
    Join Date
    Jan 2004
    Location
    South Africa
    Posts
    3

    Unhappy Unanswered: SQL Statements

    Hi! Guys

    It's me again

    I need help with executing sql statements within VB and displaying results on a textbox.

    e.g Select ContactName from Customers where CustomerID = 'ALFKI'

    I want to display the contact name on a textbox (either by sending the sql result to a variable then binding the variable to the textbox or by sending the sql result directly to the textbox).

    Please help

  2. #2
    Join Date
    Oct 2003
    Location
    BA, Argentina
    Posts
    39

    Re: SQL Statements

    You have to open a recordset and read the ContactName you want from there:

    dim rs as recordset, sSql as string
    set rs = new recordset
    sSql = "Select ContactName from Customers " & _
    "where CustomerID = 'ALFKI'"

    rs.open sSql, conn

    text1=rs.fields("ContactName")
    rs.close

  3. #3
    Join Date
    Jan 2004
    Posts
    184

    Re: SQL Statements

    Hello Thato,

    Jigarzon's answer only displays the result in the text box. If you want changes made to the text box to be reflected in your database it is easier to bind the control and then update the recordset, like this:

    Set txtCustomerName.DataSource = Recordset
    txtCustomerName.DataField = "CustomerName"

    Like I mentionned last time try out this control which automates all the ADO work for you:

    http://www.geocities.com/scirocco_ha/DataControl.htm

    Originally posted by Thato
    Hi! Guys

    It's me again

    I need help with executing sql statements within VB and displaying results on a textbox.

    e.g Select ContactName from Customers where CustomerID = 'ALFKI'

    I want to display the contact name on a textbox (either by sending the sql result to a variable then binding the variable to the textbox or by sending the sql result directly to the textbox).

    Please help

Posting Permissions

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