how can i display data in textbox from choosen dropdown menu?

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 18
Reputation: lacaroix is an unknown quantity at this point 
Solved Threads: 0
lacaroix lacaroix is offline Offline
Newbie Poster

how can i display data in textbox from choosen dropdown menu?

 
0
  #1
Mar 13th, 2008
im a beginner in vb.net.im developing for myproject in windows application.my ques:how can i display data in textbox from choosen dropdown menu?user choose a item in combobox,then after click a button the meaning of data appear in textbox..i need some help..tq in advance
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 33
Reputation: leokuz is an unknown quantity at this point 
Solved Threads: 0
leokuz leokuz is offline Offline
Light Poster

Re: how can i display data in textbox from choosen dropdown menu?

 
0
  #2
Mar 13th, 2008
Do you really need to click that button? If so, then double click your button and past following code in it:

  1. 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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 18
Reputation: lacaroix is an unknown quantity at this point 
Solved Threads: 0
lacaroix lacaroix is offline Offline
Newbie Poster

Re: how can i display data in textbox from choosen dropdown menu?

 
0
  #3
Mar 13th, 2008
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~
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: how can i display data in textbox from choosen dropdown menu?

 
0
  #4
Mar 13th, 2008
  1. Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
  2. textbox1.Text = ComboBox1.SelectedItem
  3. End Sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 18
Reputation: lacaroix is an unknown quantity at this point 
Solved Threads: 0
lacaroix lacaroix is offline Offline
Newbie Poster

Re: how can i display data in textbox from choosen dropdown menu?

 
0
  #5
Mar 17th, 2008
oh thanks..sorry for the late reply..neway i tried.i think there might haf some problems wif my connection string..its stil error..so mybe i need to figure it out wat happen act..
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: how can i display data in textbox from choosen dropdown menu?

 
0
  #6
Mar 17th, 2008
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 *
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 18
Reputation: lacaroix is an unknown quantity at this point 
Solved Threads: 0
lacaroix lacaroix is offline Offline
Newbie Poster

Re: how can i display data in textbox from choosen dropdown menu?

 
0
  #7
Mar 18th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 18
Reputation: lacaroix is an unknown quantity at this point 
Solved Threads: 0
lacaroix lacaroix is offline Offline
Newbie Poster

Re: how can i display data in textbox from choosen dropdown menu?

 
0
  #8
Mar 18th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: how can i display data in textbox from choosen dropdown menu?

 
0
  #9
Mar 19th, 2008
this following code to read data and display on combo box, u just put on event like "form load":

  1. Public Function GetConnect()
  2. Dim conn As SqlConnection
  3. conn = New SqlConnection("server = jery;database = VBtoC#;Trusted_Connection = yes")
  4. Return conn
  5. End Function
  6.  
  7.  
  8. Private Sub ReadData()
  9. Dim i As Integer
  10. Dim cmdStudent As New SqlCommand
  11. Dim daStudent As New SqlDataAdapter
  12. Dim dsStudent As New DataSet
  13. Dim dtStudent As New DataTable
  14. Dim conn As SqlConnection
  15.  
  16. conn = GetConnect()
  17. Try
  18.  
  19. cmdStudent = conn.CreateCommand
  20. cmdStudent.CommandText = "SELECT * FROM Student"
  21. daStudent.SelectCommand = cmdStudent
  22. daStudent.Fill(dsStudent, "Student") ' Table Name
  23. dtStudent = dsStudent.Tables("Student") 'Table Name
  24. For i = 0 To dtStudent.Rows.Count - 1
  25. cmbNis.Items.Add(dtStudent.Rows(i).Item(0))
  26. Next
  27.  
  28. Catch ex As Exception
  29. MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Connection Error !!")
  30. End Try
  31. conn.Close()
  32. End Sub
Hope this helps..
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 *
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 18
Reputation: lacaroix is an unknown quantity at this point 
Solved Threads: 0
lacaroix lacaroix is offline Offline
Newbie Poster

Re: how can i display data in textbox from choosen dropdown menu?

 
0
  #10
Mar 19th, 2008
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..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC