If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > SQL Statements

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-11-04, 03:16
Thato Thato is offline
Registered User
 
Join Date: Jan 2004
Location: South Africa
Posts: 3
Unhappy 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
Reply With Quote
  #2 (permalink)  
Old 02-18-04, 07:06
jigarzon jigarzon is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 02-21-04, 08:25
rami.haddad rami.haddad is offline
Registered User
 
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

Quote:
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On