Library code snippets
DataControl Example
By James Crowley, published on 14 Jul 2001
A simple example of using the DataControl to browse a database
Related articles
Related discussion
-
Regarding Visual Basic Programme
by manjunathsl2007 (0 replies)
-
how do you hide all in VB6
by CapnJack (1 replies)
-
Problem with Input File
by novavb6 (3 replies)
-
How to produce a txt file with a table??
by novavb6 (1 replies)
-
VB6 compatability from XP to Vista
by bronx (1 replies)
Private Sub txtAutoEno_KeyPress(KeyAscii As Integer)
Dim eno As String
Dim Srchflag As Boolean
Srchflag = False 'Initially Search is not found
'assigning Srch value
eno = txtAutoEno.Text
'If enter is pressed by user than auto-generate record
If KeyAscii = 13 Then
'Prompt if invalid search key is entered by user
If Not IsNumeric(eno) Then
MsgBox "Invalid Search Key Entered", vbCritical, "Search Error"
clearAndFocus
Exit Sub
End If
rs.Close
rs.Open "Select * from emp where empid = " & eno, cn, adOpenDynamic, adLockOptimistic
If rs.EOF <> True Then
Call display 'If Search is found
Srchflag = True
clearAndFocus
Exit Sub
End If
If Srchflag = False Then 'Display msg when search not found
MsgBox "Search Not Found", vbInformation, "Search Result"
clearAndFocus
End If
End If
End Sub
'Clear TextBox and SetFocus on it for fast and efficient result
Private Sub clearAndFocus()
txtAutoEno.Text = ""
txtAutoEno.SetFocus
End Sub
'Supporting Function
'Displaying Data into textbox from record source
Private Sub display()
txtEno.Text = Str(rs(0)) & " " 'Space is appended to avoid error when value is null
txtEName.Text = rs(1) & " "
txtESal.Text = Str(rs(2)) & " "
txtEstatus.Text = rs(3) & " " 'as salary is numeric it is converted to string
txtEDoj.Text = Str(rs(4)) & " "
txtEDeptNo.Text = Str(rs(5)) & " "
End Sub
'Supporting Function
'Simple clearing of textBox
Private Sub clear()
txtEno.Text = ""
txtEName.Text = ""
txtESal.Text = ""
txtEstatus.Text = ""
txtEDeptNo.Text = ""
End Sub
'Supporting Function
'Assigning value of textbox to record source
Private Sub assign()
rs(0) = Val(txtEno.Text) 'val function will Convert text to numerice
rs(1) = txtEName.Text
rs(2) = Val(txtESal.Text)
rs(3) = txtEstatus.Text
rs(4) = txtEDoj.Text
rs(5) = Val(txtEDeptNo.Text)
End Sub
Basically am trying to search a database by getting an input from the users selection on a list.
the list contains names of countries and when i click that search button, how can i get the result of the search, say like i click paris and in the database, the flight to paris has 8 more available seats and the date, how can i show this information, by using a datagrid? if so how can i link, i know there are alot of "how's" in there but i would be realy and trually greatful if u can spare a minute.
Cheers
This thread is for discussions of DataControl Example.