Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Listbox to textboxes

Listbox to textboxes

Scheduled Pinned Locked Moved Visual Basic
databasehelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hendrikbez
    wrote on last edited by
    #1

    I am trying to when I click on a name in linkbox1 to show all the data in access database table in my texboxes. But it gives me this error "No value given for one or more required parameters" Here are my Code. Don't know why it is not working Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged Dim SqlStr As String SqlStr = "Select * from tblokkies where luidraad = " & ListBox1.Items(ListBox1.SelectedIndex) FillTextBox(SqlStr) End Sub Public Function FillTextBox(ByVal Sqlstring As String) Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString) OleDbConn.Open() Dim MyDataReader As OleDbDataReader Dim MyOleDbCommand As OleDbCommand = New OleDbCommand() MyOleDbCommand.Connection = (OleDbConn) MyOleDbCommand.CommandText = Sqlstring MyDataReader = MyOleDbCommand.ExecuteReader Try Do While MyDataReader.Read TxtLuidraad.Text = (MyDataReader.Item(1)) txtA1.Text = (MyDataReader.Item(2)) txtA2.Text = (MyDataReader.Item(3)) txtA3.Text = (MyDataReader.Item(4)) txtA4.Text = (MyDataReader.Item(5)) txtA5.Text = (MyDataReader.Item(6)) txtA6.Text = (MyDataReader.Item(7)) txtA7.Text = (MyDataReader.Item(8)) txtA8.Text = (MyDataReader.Item(9)) txtA9.Text = (MyDataReader.Item(10)) txtA10.Text = (MyDataReader.Item(11)) Loop Catch err As System.Exception MyDataReader.Close() OleDbConn.Close() OleDbConn.Dispose() End Try End Function

    C 1 Reply Last reply
    0
    • H hendrikbez

      I am trying to when I click on a name in linkbox1 to show all the data in access database table in my texboxes. But it gives me this error "No value given for one or more required parameters" Here are my Code. Don't know why it is not working Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged Dim SqlStr As String SqlStr = "Select * from tblokkies where luidraad = " & ListBox1.Items(ListBox1.SelectedIndex) FillTextBox(SqlStr) End Sub Public Function FillTextBox(ByVal Sqlstring As String) Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString) OleDbConn.Open() Dim MyDataReader As OleDbDataReader Dim MyOleDbCommand As OleDbCommand = New OleDbCommand() MyOleDbCommand.Connection = (OleDbConn) MyOleDbCommand.CommandText = Sqlstring MyDataReader = MyOleDbCommand.ExecuteReader Try Do While MyDataReader.Read TxtLuidraad.Text = (MyDataReader.Item(1)) txtA1.Text = (MyDataReader.Item(2)) txtA2.Text = (MyDataReader.Item(3)) txtA3.Text = (MyDataReader.Item(4)) txtA4.Text = (MyDataReader.Item(5)) txtA5.Text = (MyDataReader.Item(6)) txtA6.Text = (MyDataReader.Item(7)) txtA7.Text = (MyDataReader.Item(8)) txtA8.Text = (MyDataReader.Item(9)) txtA9.Text = (MyDataReader.Item(10)) txtA10.Text = (MyDataReader.Item(11)) Loop Catch err As System.Exception MyDataReader.Close() OleDbConn.Close() OleDbConn.Dispose() End Try End Function

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Wow, is your code ever illegible. Is this deliberate ? What type is luidraad ? Should the item be in quotes ? What line is blowing up ? Have you stepped through the code to see if the returned data has that many items in it ? Does VB really index by 1 instead of by 0 ? I guess it would.

      Christian Graus Driven to the arms of OSX by Vista.

      H 1 Reply Last reply
      0
      • C Christian Graus

        Wow, is your code ever illegible. Is this deliberate ? What type is luidraad ? Should the item be in quotes ? What line is blowing up ? Have you stepped through the code to see if the returned data has that many items in it ? Does VB really index by 1 instead of by 0 ? I guess it would.

        Christian Graus Driven to the arms of OSX by Vista.

        H Offline
        H Offline
        hendrikbez
        wrote on last edited by
        #3

        Sorry my engilsh is not so good, what do you mean by illegble and deliberate. Is there onther way do this this codeing. Luidraad type = text (150) No quotes Can not see waht line is blowing up. Did step true here is what I get when I press F8. 1. Click on 4th entry in listbox1 (Hendrik) 2. Dim Sqlstr as string (Sqlstr Nothing) 3. After F8 = Dim Sqlstr as string (Sqlstr "Select *from tblokkies where luidraad=Hendrik") 4. listbox1.items(listbox1.selectedindex) (Listbox1.items {System.Windows.forms.listbox.objectcollection) 5 After F8 = listbox1.items(listbox1.selectedindex) (Listbox1.selectedindex 4) 6. Filltextbox(Sqlstr) (Filltextbox Nothing) 7. Dim Oledbconn as oledbconnection = new oledbconnection(Connstring) (OleDbConn {system.data.oleDbConnection} (ConnectionString "Provider=microsoft.jet.oledb.4.0;data source=c:\blokkies\blokkies.mdb" (ConnectionTimeout 15 (Conteiner nothing (Database "" (DataSource "c:\blokkies\blokkies.mdb" (Provider "Microsoft.jet.oledb.4.0" (Serverversion {"invalid operation. The connection is closed"} (Site Nothing (State Closed {0} 8. dim myoledbcommand nothing dbconn 9. after F8 (Myoledbcommand {system.data.oledb.oledbcommand} (commandtext "" (Commandtimeout 30 (commandtype text {1} (connection nothing (container nothing (designtimevisible true (parameters {system.data.oledb.oleparametercollection} (Site nothing (transaction nothing (updatedrowsource both {3} 10. myoledbcommand.connection = (oledbconn) (OleDbConn {system.data.oleDbConnection} (ConnectionString "Provider=microsoft.jet.oledb.4.0;data source=c:\blokkies\blokkies.mdb" (ConnectionTimeout 15 (Conteiner nothing (Database "" (DataSource "c:\blokkies\blokkies.mdb" (Provider "Microsoft.jet.oledb.4.0" (Serverversion "04.00.0000" (Site Nothing (State open {1} 11. myoledbcommand.commandtext =sqlstring = myoledbcommand.commandtext "" 12. After F8 =sqlstring = "select*from tblokkies where luidraad=Hendrik"

        C 1 Reply Last reply
        0
        • H hendrikbez

          Sorry my engilsh is not so good, what do you mean by illegble and deliberate. Is there onther way do this this codeing. Luidraad type = text (150) No quotes Can not see waht line is blowing up. Did step true here is what I get when I press F8. 1. Click on 4th entry in listbox1 (Hendrik) 2. Dim Sqlstr as string (Sqlstr Nothing) 3. After F8 = Dim Sqlstr as string (Sqlstr "Select *from tblokkies where luidraad=Hendrik") 4. listbox1.items(listbox1.selectedindex) (Listbox1.items {System.Windows.forms.listbox.objectcollection) 5 After F8 = listbox1.items(listbox1.selectedindex) (Listbox1.selectedindex 4) 6. Filltextbox(Sqlstr) (Filltextbox Nothing) 7. Dim Oledbconn as oledbconnection = new oledbconnection(Connstring) (OleDbConn {system.data.oleDbConnection} (ConnectionString "Provider=microsoft.jet.oledb.4.0;data source=c:\blokkies\blokkies.mdb" (ConnectionTimeout 15 (Conteiner nothing (Database "" (DataSource "c:\blokkies\blokkies.mdb" (Provider "Microsoft.jet.oledb.4.0" (Serverversion {"invalid operation. The connection is closed"} (Site Nothing (State Closed {0} 8. dim myoledbcommand nothing dbconn 9. after F8 (Myoledbcommand {system.data.oledb.oledbcommand} (commandtext "" (Commandtimeout 30 (commandtype text {1} (connection nothing (container nothing (designtimevisible true (parameters {system.data.oledb.oleparametercollection} (Site nothing (transaction nothing (updatedrowsource both {3} 10. myoledbcommand.connection = (oledbconn) (OleDbConn {system.data.oleDbConnection} (ConnectionString "Provider=microsoft.jet.oledb.4.0;data source=c:\blokkies\blokkies.mdb" (ConnectionTimeout 15 (Conteiner nothing (Database "" (DataSource "c:\blokkies\blokkies.mdb" (Provider "Microsoft.jet.oledb.4.0" (Serverversion "04.00.0000" (Site Nothing (State open {1} 11. myoledbcommand.commandtext =sqlstring = myoledbcommand.commandtext "" 12. After F8 =sqlstring = "select*from tblokkies where luidraad=Hendrik"

          C Offline
          C Offline
          celso_cabaleiro
          wrote on last edited by
          #4

          hendrikbez wrote:

          12. After F8 =sqlstring = "select*from tblokkies where luidraad=Hendrik" = myoledbcommand.commandtext = "select*from tblokkies where luidraad=Hendrik"

          I think Hendrik must be enclosed with '. SqlStr = "Select * from tblokkies where luidraad = '" & ListBox1.Items(ListBox1.SelectedIndex) & "'" try with select * from tblokkies where luidraad='Hendrik' from Access

          H 1 Reply Last reply
          0
          • C celso_cabaleiro

            hendrikbez wrote:

            12. After F8 =sqlstring = "select*from tblokkies where luidraad=Hendrik" = myoledbcommand.commandtext = "select*from tblokkies where luidraad=Hendrik"

            I think Hendrik must be enclosed with '. SqlStr = "Select * from tblokkies where luidraad = '" & ListBox1.Items(ListBox1.SelectedIndex) & "'" try with select * from tblokkies where luidraad='Hendrik' from Access

            H Offline
            H Offline
            hendrikbez
            wrote on last edited by
            #5

            celso_cabaleiro Thank you it is working. I don't know how to do it, can you help me with this please I want to use txtluidraad.text to do a search, and then when I type in the word, listbox must go to that one, must I add a new listbox or will the one that I have work. I don 't know how to use a search at all. Hope you can help me.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups