473,729 Members | 2,309 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to give an SQL statement in combobox(Visual basic 6.0)

58 New Member
Hi everyone..

I want to insert a combobox with the list of test names of a database, but the testname contains 15000+ data, and I cant type all the data. so can any one help me in writing an SQL statement, so that if I give that statement it will automatically swaps the table names to the combobox.

P.S I know the SQL statement but I dono where to give that SQL statement in combobox

explanation with program will be verymuch helpfull for me

Thanks in advance

Regards
Siva
Mar 31 '09 #1
5 6067
debasisdas
8,127 Recognized Expert Expert
you just need to go 1...2...3

1.Create a connection
2. open the recordset
3. in a loop add the items from recordset to combobox.
Mar 31 '09 #2
sivadhanekula
58 New Member
haaa....I am totally new to Visual basic....I am not able to understand what you are telling...can you explain in detail...plzz.. .I have done some program to extract the data...in the program if you look at the SQL statement(under lined) I want to insert all the values of fullname into the combo box, so that if I select one of the fullname then the data regarding that fullname should be extracted and should be displayed after pressing the Ok button

Private Sub Okbutton_Click( )
On Error Resume Next

Dim sConnect As String
Dim db As Database
Dim rs As Recordset
Dim Ws As Workspace
'Dim ID As Double
'Dim doubleID1 As Double
Dim intstring As String

Set Ws = DBEngine.Worksp aces(0)

sConnect = "ODBC;DSN=WinUT MS_RT_DB;UID=Lo calhost;PWD=;Da tabase=WinUTMS_ RT_DB;"

Set db = Ws.OpenDatabase ("", 0, 0, sConnect)

Set rs = db.OpenRecordse t("SELECT Fullname FROM abssubtest")
Do While Not rs.EOF
'ID = rs!Messwert
'doubleID1 = rs!UPLimWert
intstring = rs.Fields("Full name")
rs.MoveNext
Loop
End Sub
Mar 31 '09 #3
EYE4U
75 New Member
I have made some changes to your loop....

Expand|Select|Wrap|Line Numbers
  1. Do While Not rs.EOF
  2. 'ID = rs!Messwert
  3. 'doubleID1 = rs!UPLimWert
  4. combo1.add (rs.Fields("Fullname"))
  5. rs.MoveNext
  6. Loop
  7. End Sub
Regards
ARUZ
Apr 4 '09 #4
sivadhanekula
58 New Member
Private Sub Combo1_Click()

Label1.Caption = "find" & Combo1.Text
Label1.Visible = True

End Sub

Private Sub Form_Load()
On Error Resume Next

Label1.Visible = False
DataGrid1.Visis ble = False

Dim cn As ADODB.Connectio n
Dim rs As ADODB.Recordset

Set cn = New ADODB.Connectio n
cn.ConnectionSt ring = "ODBC;DSN=WinUT MS_RT_DB;UID=Lo calhost;PWD=;Da tabas e=WinUTMS_RT_DB ;"
cn.Open

Set rs = New ADODB.Recordset
rs.Open "absprfg", cn, adOpenKeyset, adLockPessimist ic, adCmdTable

Do While Not rs.EOF
Combo1.AddItem rs.Fields("Modu s")
rs.MoveNext
Loop
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
End If
End Sub
Private Sub Command1_Click( )
On Error Resume Next
Me.Form.RecordS ource = "SELECT Fullname FROM abssubtest & ComboBox.Value & " ';"

Me.Requery
End Sub

Private Sub Label1_Click()
DataGrid1.Visib le = True

Adodc1.CommandT ype = adCmdText
Adodc1.RecordSo urce = "select absprfg.Modus From absprfg WHERE absprfg.Modus=' " & Combo1.Text & "' "
Adodc1.Refresh

End Sub
I have done the above program..but after pressing the run button..I am getting the blank screen and after some time the vb is not responding and I have to close the program...even I have seen it with break point but of no use....can you please tell me where I have done the mistake...

Regards
Siva
Apr 6 '09 #5
EYE4U
75 New Member
I think at this line your are having problem.
Expand|Select|Wrap|Line Numbers
  1. Me.Form.RecordSource = "SELECT Fullname FROM abssubtest & ComboBox.Value & " ';"
Apr 6 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1842
by: Tech | last post by:
In Visual Basic 6.0, the Locked property of a ComboBox control determined whether the text-box portion of the control could be edited. In Visual Basic ..NET, the Locked property prevents a control from being moved at design time. There is no direct equivalent for the Visual Basic 6.0 Locked property. What to do next Change the DropDownStyle property of the ComboBox control to DropDownList. Note In Visual Basic 6.0, setting the...
9
56520
by: Steffen Laser | last post by:
Hi group, I have a problem that I already have posted to the german C# newsgroup. Since nobody could help me there, I'd like to try it here again: I set the selected item of a combobox like this: myCombo.SelectedItem = 3; But after that the ComboBox displays only the first entry of the list. When I add the line
2
3053
by: jaYPee | last post by:
i have successfully added a combobox control in datagrid. this is the code i have created but don't show up the record from another table. Private Sub AddCustomDataTableStyle() Dim ts1 As DataGridTableStyle ts1 = New DataGridTableStyle() ts1.MappingName = "SchYrSemCourseJoin" ' Set other properties. ts1.AlternatingBackColor = Color.LightGray
6
3129
by: Juan Pedro Gonzalez | last post by:
I wanted to add a Combobox to a toolbar... Kind of the look you get on VisualStudio's toolbar. I've been able to find some VB 6 samples, but the placeholder option is no longer available for ToolbarButtons... Does anyone know how this could be done? Looking forward to hear from you,
9
3866
by: paul c | last post by:
Apologies if I'm sending this to the wrong group. If so I'd be grateful if somebody could point me to the right one. I'm using microsoft visual c++ 6.0 compiler. My code is C, I just use the c++ compiler for easier positioning of declarations here and there. I am putting together a small interpreter that will do a great deal of iteration and I'd like to avoid using function pointers to my opcode
10
2088
by: news.microsoft.com | last post by:
I am new to this so bear with me. I have a set of combo boxes. Lets call them ComboBox1 and ComboBox2. ComboBox1 items are pulled from a table. When a user selects a certain item I want to disable ComboBox2. i can make this work in Visual Web Developer, but have been unsuccessful in Visual Basic 2005.
3
6679
by: marknoten | last post by:
I'm quite a newbie to Visual Basic and have a problem with the Input # statement in the Visual Basic Editor from Excel. I would like to read in a tab delimeted text file selected by a user with records like this: <snip> O 21.266 17.733 28.155 N 20.649 17.703 30.320 C 20.883 17.336 31.723 </snip> I'm using the code below to read each line from the file and store them in the variables organicAtom, xCoord, yCoord and zCoord. The problem...
0
1202
by: evlpupy | last post by:
Good Afternoon I have need of assistance for programming a visual basic form in excel. In excel I have 3 named ranges TM Agents1 Agents2 In the TM range I have 5 different names of managers (ie Tom Smith, Bob Green, etc.)
2
2110
by: Bruno43 | last post by:
Hi I have a question about the Combo Box This is the only Code I have seemed to be able to find to add items to a Combo Box... Is there a way to modify it or another command that I could use to have my own index or value inserted, but display the text NewField Me.evSelectName.Items.Add("NewField") So that when the click 'NewField' the value stored/read would equal something else? Thanks in advance!
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.