0

i have made a database in sql+. it has a database. there is a table project. its columns are p_id,p_name,p_manager.

i have inserted 5 rows in above table.

in d front end in vb6 i have a form . please help me with the code such that my p_id is a combobox. wen i select my p_id then the corresponding p_name and P_manager should be displayed in text box on the form. please help!

thank you!

Edited by ss123456: bad title

3
Contributors
5
Replies
8
Views
4 Years
Discussion Span
Last Post by ss123456
0
'Try this code


con.open

sql = "SELECT * FROM YOUR TABLE WHERE P_ID = " & YourTextBox & "
cmd = New oledb.oledbcommand(sql,con) 'cmd = command. con = connection
dr = cmd.executereader  'This would be your data reader

while dr.read
    textboxPName = dr("p_name")
    textboxPManager = dr("p_manager")
end while

con.close

Edited by Denden17

0

i currently enter p_id through sql query into the database.
this is the code i use to enter values into project.

con.Execute "insert into project values (" + Text1.Text + ",'" + Text2.Text + "','" + Text3.Text + "')"
MsgBox "Project Added Successfully!!"
Text1.Text = ""                          'for id
Text2.Text = ""                          'for name
Text3.Text = ""                          'for manager

how do i get the values of p_id into my combo box?

0
ok. if you want to put all the ID in the combobox.

put this into your Form Load Event.

Con.open
sql = "SELECT p_id FROM YOURTABLE"
cmd = New Oledb.OledbCommand(sql,con)
dr = cmd.executereader

while dr.read
    Combobox.items.add(dr("p_id"))
end while

con.close
0

the following line is shown in red

cmd = New Oledb.OledbCommand(sql,con)

please note i use adodb connection in vb 6.0 tp connect to sql database. how do i correct it?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.