| | |
how can i display data in textbox from choosen dropdown menu?
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2008
Posts: 33
Reputation:
Solved Threads: 0
Do you really need to click that button? If so, then double click your button and past following code in it:
otherwise you can double click your combobox a paste same code in there instead. That will save you extra click (won't need to click button to see combobox selection in textbox as it will appear automatically).
Hope this helps.
P.S. of course don't forget to modify textbox and combobox names if they are different.
VB.NET Syntax (Toggle Plain Text)
TextBox1.Text = ComboBox1.Text
otherwise you can double click your combobox a paste same code in there instead. That will save you extra click (won't need to click button to see combobox selection in textbox as it will appear automatically).
Hope this helps.
P.S. of course don't forget to modify textbox and combobox names if they are different.
•
•
Join Date: Mar 2008
Posts: 18
Reputation:
Solved Threads: 0
okay.i try to run..there's an erorr about connection string..
"An unhandled exception of type 'System.ArgumentException' occurred in System.Data.SqlClient.dll
Additional information: Unknown connection option in connection string: driver."
im not veru sure about the coding to connection of database..any advice?tq~
"An unhandled exception of type 'System.ArgumentException' occurred in System.Data.SqlClient.dll
Additional information: Unknown connection option in connection string: driver."
im not veru sure about the coding to connection of database..any advice?tq~
vb.net Syntax (Toggle Plain Text)
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged textbox1.Text = ComboBox1.SelectedItem End Sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
what database that u using on?sqlserver or access?
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Mar 2008
Posts: 18
Reputation:
Solved Threads: 0
im using sqlserver..act im not sure wat my prob is..here my coding for click button..afta i run the application there the error sed
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.SqlClient.dll
Additional information: The ConnectionString property has not been initialized.
here my coding...
Dim connectionString As String = "Driver={MySQL};SERVER=MUBINZ;DATABASE=japanese;"
Dim conManager As String = ""
Dim com As New SqlCommand
Dim conn As New SqlConnection'open connection
Dim text As String = TextBox1.Text
Dim list As String = ComboBox1.SelectedValue
Dim da As SqlDataAdapter
Dim ds As DataSet
Dim dr As SqlDataReader
Dim sql As String
conn.Open()
list = Me.ComboBox1.Items("Good morning") = 0
sql = "select translation_japan from table_greeting where greet_id = & Good morning.selectedvalue"
com.CommandText = sql
conn.ConnectionString = connectionString
com.Connection = conn
dr = com.ExecuteReader()
While dr.Read
text = dr.GetValue(0)
End While
TextBox1.Text = text
conn.Close()
End Sub
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.SqlClient.dll
Additional information: The ConnectionString property has not been initialized.
here my coding...
Dim connectionString As String = "Driver={MySQL};SERVER=MUBINZ;DATABASE=japanese;"
Dim conManager As String = ""
Dim com As New SqlCommand
Dim conn As New SqlConnection'open connection
Dim text As String = TextBox1.Text
Dim list As String = ComboBox1.SelectedValue
Dim da As SqlDataAdapter
Dim ds As DataSet
Dim dr As SqlDataReader
Dim sql As String
conn.Open()
list = Me.ComboBox1.Items("Good morning") = 0
sql = "select translation_japan from table_greeting where greet_id = & Good morning.selectedvalue"
com.CommandText = sql
conn.ConnectionString = connectionString
com.Connection = conn
dr = com.ExecuteReader()
While dr.Read
text = dr.GetValue(0)
End While
TextBox1.Text = text
conn.Close()
End Sub
•
•
Join Date: Mar 2008
Posts: 18
Reputation:
Solved Threads: 0
sorry..here my coding...the error stil the same..there an arrow shoe at the
conn.Open()
thanks you in advanced..
Dim connectionString As String = "Driver={MySQL};SERVER=MUBINZ;DATABASE=japanese;"
Dim conManager As String = ""
Dim com As New SqlCommand
Dim conn As New SqlConnection'open connection
Dim text As String = TextBox1.Text
Dim temp As String = ComboBox1.SelectedItem
Dim da As SqlDataAdapter
Dim ds As DataSet
Dim dr As SqlDataReader
Dim sql As String
conn.Open()
temp = ComboBox1.SelectedItem
sql = "select translation_japan from table_greeting where greet_id = '" & temp & "'"
com.CommandText = sql
conn.ConnectionString = connectionString
com.Connection = conn
dr = com.ExecuteReader()
While dr.Read
text = dr.GetValue(0)
End While
TextBox1.Text = text
conn.Close()
End Sub
conn.Open()
thanks you in advanced..
Dim connectionString As String = "Driver={MySQL};SERVER=MUBINZ;DATABASE=japanese;"
Dim conManager As String = ""
Dim com As New SqlCommand
Dim conn As New SqlConnection'open connection
Dim text As String = TextBox1.Text
Dim temp As String = ComboBox1.SelectedItem
Dim da As SqlDataAdapter
Dim ds As DataSet
Dim dr As SqlDataReader
Dim sql As String
conn.Open()
temp = ComboBox1.SelectedItem
sql = "select translation_japan from table_greeting where greet_id = '" & temp & "'"
com.CommandText = sql
conn.ConnectionString = connectionString
com.Connection = conn
dr = com.ExecuteReader()
While dr.Read
text = dr.GetValue(0)
End While
TextBox1.Text = text
conn.Close()
End Sub
this following code to read data and display on combo box, u just put on event like "form load":
Hope this helps..
vb.net Syntax (Toggle Plain Text)
Public Function GetConnect() Dim conn As SqlConnection conn = New SqlConnection("server = jery;database = VBtoC#;Trusted_Connection = yes") Return conn End Function Private Sub ReadData() Dim i As Integer Dim cmdStudent As New SqlCommand Dim daStudent As New SqlDataAdapter Dim dsStudent As New DataSet Dim dtStudent As New DataTable Dim conn As SqlConnection conn = GetConnect() Try cmdStudent = conn.CreateCommand cmdStudent.CommandText = "SELECT * FROM Student" daStudent.SelectCommand = cmdStudent daStudent.Fill(dsStudent, "Student") ' Table Name dtStudent = dsStudent.Tables("Student") 'Table Name For i = 0 To dtStudent.Rows.Count - 1 cmbNis.Items.Add(dtStudent.Rows(i).Item(0)) Next Catch ex As Exception MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Connection Error !!") End Try conn.Close() End Sub
Last edited by Jx_Man; Mar 19th, 2008 at 1:50 am. Reason: add connection function
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Mar 2008
Posts: 18
Reputation:
Solved Threads: 0
the code will dispay on the combo box rite?
nway mine is select frm the combo box(a japanese word)and displaying in text box which the textbox(english word) will retrieved the data form the database...its sumthing like a dictionary but its simpler than dictionry..
sorry for the trouble but im a bit blurr in tis coding...thanks in advance..
nway mine is select frm the combo box(a japanese word)and displaying in text box which the textbox(english word) will retrieved the data form the database...its sumthing like a dictionary but its simpler than dictionry..
sorry for the trouble but im a bit blurr in tis coding...thanks in advance..
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: Timer Control Question
- Next Thread: VB Woes
| Thread Tools | Search this Thread |
.net .net2008 2008 access account add advanced application array basic beginner browser button buttons click code combo cpu cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic employees excel exists fade filter forms generatetags html images input intel internet listview mobile module monitor mysql net number objects open panel passingparameters pdf picturebox picturebox2 port position print printing printpreview problem regex reuse right-to-left save search searchvb.net select serial settings shutdown socket sqldatbase sqlserver storedprocedure survey temperature textbox timer timespan transparency txttoxmlconverter update user usercontol vb vb.net vb.netformclosing()eventpictureboxmessagebox vbnet vista visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode xml year






