Click here to Skip to main content
15,924,507 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: how to position a form off the screen? Pin
ns27-Sep-02 9:40
ns27-Sep-02 9:40 
Questionhandle to child window...how to? Pin
ns26-Sep-02 4:28
ns26-Sep-02 4:28 
GeneralCollection of my own type Pin
Jerome Conus26-Sep-02 3:40
Jerome Conus26-Sep-02 3:40 
GeneralRe: Collection of my own type Pin
mikasa26-Sep-02 6:03
mikasa26-Sep-02 6:03 
Generalsending message from a VC dll to VB - user defined Pin
ns26-Sep-02 3:20
ns26-Sep-02 3:20 
QuestionZoomable image overlaid with drawing possible? Pin
Bodie25-Sep-02 13:58
Bodie25-Sep-02 13:58 
Questionhow to bind data with textbox after executing search query thru code? Pin
drmzunlimited25-Sep-02 11:43
drmzunlimited25-Sep-02 11:43 
AnswerRe: how to bind data with textbox after executing search query thru code? Pin
Peet Schultz26-Sep-02 0:39
Peet Schultz26-Sep-02 0:39 
Hi There

If you are going to use the resultset for display purpose only, it is better to use the datareader to retrieve the data as in the following piece of code.

The code shows how to read the sql results into a combo box, but you would do the same for a text box (given that you only return one row from the db)

I think it would also be easier to read the parameters from the input text boxes as you build up the sql string, ie:

sSQl = "select * from publishers where name = " + txtName.text + " and date ........" etc

Private Sub LoadInitData()

Dim sConnect As String
Dim sCategory As String
Dim sType As String
Dim sPrinter As String
Dim odrCategory As OleDb.OleDbDataReader
Dim odrType As OleDb.OleDbDataReader
Dim odrPrinter As OleDb.OleDbDataReader
Dim oConnection As OleDb.OleDbConnection = New OleDb.OleDbConnection()
Dim oCommand As OleDb.OleDbCommand = New OleDb.OleDbCommand()
Dim sDBPath As String

sDBPath = Application.StartupPath

sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath & "\Inks.MDB"
sCategory = "SELECT CATEGORY.CATEGORY FROM CATEGORY ORDER BY CATEGORY.CATEGORY"

Try
oConnection.ConnectionString = sConnect
oConnection.Open()
'get categories
oCommand.CommandText = sCategory
oCommand.Connection = oConnection
odrCategory = oCommand.ExecuteReader

While odrCategory.Read
Me.cmbCategory.Items.Add(odrCategory.GetString(0))
End While

If cmbCategory.Items.Count > 0 Then
cmbCategory.SelectedIndex = 0
End If

odrCategory.Close()

oConnection.Close()

Catch o As System.Exception
MsgBox(o.Message)
Exit Sub
End Try

End Sub


YASP
GeneralHELP! Looking for Coyote Software ActiveX Control - MC ComboBox Pin
Throttles25-Sep-02 10:36
Throttles25-Sep-02 10:36 
Generalproblem with disabling button in toolbar (VBA in Word97) Pin
Mariusz Popiolek25-Sep-02 8:26
sussMariusz Popiolek25-Sep-02 8:26 
GeneralTransparent Child Forms in VB.NET Pin
mikasa25-Sep-02 7:32
mikasa25-Sep-02 7:32 
Questionwhich files to distribute for COM dll? Pin
ns25-Sep-02 5:35
ns25-Sep-02 5:35 
GeneralDatagrid Copy/Paste Rows Pin
b376724-Sep-02 15:16
b376724-Sep-02 15:16 
Generalsendmessage woes..... Pin
ns24-Sep-02 10:32
ns24-Sep-02 10:32 
GeneralRe: sendmessage woes..... Pin
Nick Parker24-Sep-02 11:42
protectorNick Parker24-Sep-02 11:42 
GeneralRe: sendmessage woes..... Pin
ns25-Sep-02 0:55
ns25-Sep-02 0:55 
General3rd Party Components Pin
Anonymous24-Sep-02 5:02
Anonymous24-Sep-02 5:02 
QuestionVB runtime - how to distribute? Pin
ns24-Sep-02 1:33
ns24-Sep-02 1:33 
AnswerRe: VB runtime - how to distribute? Pin
Nick Parker24-Sep-02 2:46
protectorNick Parker24-Sep-02 2:46 
GeneralInternet Pin
Anonymous23-Sep-02 19:24
Anonymous23-Sep-02 19:24 
GeneralRe: Internet Pin
Nick Parker24-Sep-02 1:30
protectorNick Parker24-Sep-02 1:30 
GeneralPlease help Pin
Member 103967023-Sep-02 15:57
Member 103967023-Sep-02 15:57 
GeneralRe: Please help Pin
Nick Parker24-Sep-02 2:46
protectorNick Parker24-Sep-02 2:46 
GeneralBackcolour in VB6 Pin
Sas2808198623-Sep-02 9:52
Sas2808198623-Sep-02 9:52 
GeneralRe: Backcolour in VB6 Pin
Nick Parker23-Sep-02 12:12
protectorNick Parker23-Sep-02 12:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.