Click here to Skip to main content
15,796,333 members
Home / Discussions / Visual Basic
   

Visual Basic

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder12-Jul-09 23:40
cofounderChris Maunder12-Jul-09 23:40 
PinnedHow to get an answer to your question PinPopular
Chris Maunder10-Nov-05 17:30
cofounderChris Maunder10-Nov-05 17:30 
Questionmysql to tally Pin
CHANDRA SEKAR Nov202230-Nov-23 21:52
CHANDRA SEKAR Nov202230-Nov-23 21:52 
AnswerRe: mysql to tally Pin
Dave Kreskowiak1-Dec-23 5:27
mveDave Kreskowiak1-Dec-23 5:27 
QuestionHow do i populate say combobox2 depending on a *selected* ms access database table in combobox1 without writing If statements for each and every table in the database in vb.net windows forms Pin
Kudzanai Victor8-Nov-23 19:41
Kudzanai Victor8-Nov-23 19:41 
I would want to prompt user to select a tool name from combobox1, then out automatically, combobox2 gets filled with tool description and size, which is a column in the selected table. Currently i have been using the following code, however the problem comes when i would like to update the database and add another table. This would mean adding the code in the application as well. I would like the application to be able to detect that a new tool table has been added and show that automatically without having to code again



Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

' ADDING TABLE NAMES TO COMBOBOX 1 (TOOL NAME)

    con.Open()

    Dim schemaTable As DataTable = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"})

   For Each dr As DataRow In schemaTable.Rows

            Combobox1.Items.Add(dr.Item("TABLE_NAME"))

   Next

End Sub

Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Combobox1.SelectedIndexChanged          

'FILLING COMBOBOX 2 (TOOL DESCRIPTION AND SIZE) DEPENDING ON SELECTION IN COMBOBOX 1 (TOOL NAME)

 If Combobox1.SelectedIndex = 1 Then             

Combobox2.Text = ""                         

con.Open()             

Combobox2.Items.Clear()             

Dim dr As OleDbDataReader             

Dim cmd As New OleDbCommand 

cmd.CommandText = "Select * from 14_POUND_HAMMER"            

cmd.Connection = con             

dr = cmd.ExecuteReader             

While dr.Read                 

Combobox2.Items.Add(dr.GetString(1))              

End While             

dr.Close()             

con.Close()



 ElseIf Combobox1.SelectedIndex = 2 Then             

Combobox2.Text = ""                       

con.Open()             

Combobox2.Items.Clear()             

Dim dr As OleDbDataReader             

Dim cmd As New OleDbCommand             

cmd.CommandText = "Select * from 3_QUARTER_IMPACT_WRENCH"             
cmd.Connection = con             

dr = cmd.ExecuteReader             

While dr.Read                 

Combobox2.Items.Add(dr.GetString(0))             

End While             

dr.Close()             

con.Close()



ElseIf Combobox1.SelectedIndex = 3 Then             

Combobox2.Text = ""                         

con.Open()             

Combobox2.Items.Clear()             

Dim dr As OleDbDataReader             

Dim cmd As New OleDbCommand             

cmd.CommandText = "Select * from ABRASIVE_CUT_OFF_SAW "        
cmd.Connection = con             

dr = cmd.ExecuteReader             

While dr.Read                 

Combobox2.Items.Add(dr.GetString(0))             

End While             

dr.Close()             

con.Close() 

AnswerRe: How do i populate say combobox2 depending on a *selected* ms access database table in combobox1 without writing If statements for each and every table in the database in vb.net windows forms Pin
Richard MacCutchan8-Nov-23 22:39
mveRichard MacCutchan8-Nov-23 22:39 
AnswerRe: How do i populate say combobox2 depending on a *selected* ms access database table in combobox1 without writing If statements for each and every table in the database in vb.net windows forms Pin
jschell9-Nov-23 8:18
jschell9-Nov-23 8:18 
QuestionChange Field Data Type in SQLite DB and Use with changes Pin
Choroid27-Oct-23 16:47
Choroid27-Oct-23 16:47 
AnswerRe: Change Field Data Type in SQLite DB and Use with changes Pin
Richard MacCutchan27-Oct-23 23:24
mveRichard MacCutchan27-Oct-23 23:24 
GeneralRe: Change Field Data Type in SQLite DB and Use with changes Pin
Choroid28-Oct-23 9:05
Choroid28-Oct-23 9:05 
GeneralRe: Change Field Data Type in SQLite DB and Use with changes Pin
Richard MacCutchan28-Oct-23 9:54
mveRichard MacCutchan28-Oct-23 9:54 
GeneralRe: Change Field Data Type in SQLite DB and Use with changes Pin
Choroid28-Oct-23 21:57
Choroid28-Oct-23 21:57 
AnswerRe: Change Field Data Type in SQLite DB and Use with changes Pin
Dave Kreskowiak28-Oct-23 5:39
mveDave Kreskowiak28-Oct-23 5:39 
AnswerRe: Change Field Data Type in SQLite DB and Use with changes Pin
Choroid28-Oct-23 21:55
Choroid28-Oct-23 21:55 
GeneralRe: Change Field Data Type in SQLite DB and Use with changes Pin
Richard MacCutchan28-Oct-23 23:33
mveRichard MacCutchan28-Oct-23 23:33 
GeneralRe: Change Field Data Type in SQLite DB and Use with changes Pin
Choroid29-Oct-23 7:02
Choroid29-Oct-23 7:02 
GeneralRe: Change Field Data Type in SQLite DB and Use with changes Pin
Richard MacCutchan29-Oct-23 7:20
mveRichard MacCutchan29-Oct-23 7:20 
GeneralRe: Change Field Data Type in SQLite DB and Use with changes Pin
Choroid29-Oct-23 19:18
Choroid29-Oct-23 19:18 
GeneralRe: Change Field Data Type in SQLite DB and Use with changes Pin
Richard MacCutchan29-Oct-23 23:39
mveRichard MacCutchan29-Oct-23 23:39 
GeneralRe: Change Field Data Type in SQLite DB and Use with changes Pin
Choroid30-Oct-23 6:30
Choroid30-Oct-23 6:30 
GeneralRe: Change Field Data Type in SQLite DB and Use with changes Pin
Richard MacCutchan30-Oct-23 7:24
mveRichard MacCutchan30-Oct-23 7:24 
GeneralRe: Change Field Data Type in SQLite DB and Use with changes Pin
jschell31-Oct-23 6:58
jschell31-Oct-23 6:58 
GeneralRe: Change Field Data Type in SQLite DB and Use with changes Pin
Dave Kreskowiak31-Oct-23 7:42
mveDave Kreskowiak31-Oct-23 7:42 
AnswerRe: Change Field Data Type in SQLite DB and Use with changes Pin
Gerry Schmitz29-Oct-23 7:26
mveGerry Schmitz29-Oct-23 7:26 
GeneralRe: Change Field Data Type in SQLite DB and Use with changes Pin
k505429-Oct-23 8:45
mvek505429-Oct-23 8:45 

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.