first..
i hve create combobox & text box and add database source to my project...
i know how to binding data or load data to combobox using SELECT query..
but can i change SELECT to INSERT query cz i wont when i type data into textbox,data will be in database...

second..
can i binding without add database to project..i mean mydatabase in debug folder..i hve problem binding data if database is not in myproject..

your post is not clear. i can't understand what do you want to do.
1. you want to insert data in textbox to database?
2. what kind of database?access?
3. how far you doing this?

my project 90% complete..
i using accessdatabse and put in debug folder..
i know hw to using insert statment..

ok i just to know,can i binding data to combobox if database on debug folder...

still not clear..where is your code? i even didn't know what type of database connection you're using to connected.
your program is 90% completed. so, binding data is not hard to you.
how to bind it? just select the field that you want to display on combobox, read data until the last record and finish.

this following code using oledb..modified as u needed.

Private Sub ReadData()
        Dim con As New OleDb.OleDbConnection
        Dim cmdAuthor As New OleDb.OleDbCommand
        Dim dsAuthor As New DataSet
        Dim daAuthor As New OleDb.OleDbDataAdapter
        Dim dtAuthor As New DataTable
        Dim i, k As Integer

        ' Got the debug path
        con.ConnectionString = ("Provider = Microsoft.JET.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Authors.mdb")
        Try

            cmdAuthor = con.CreateCommand
            cmdAuthor.CommandText = "SELECT * FROM Authors "
            daAuthor.SelectCommand = cmdAuthor
            daAuthor.Fill(dsAuthor, "Authors")
            dtAuthor = dsAuthor.Tables("Authors")
            For i = 0 To dtAuthor.Rows.Count - 1
                cmbAuthor.Items.Add(dtAuthor.Rows(i).Item(1))
            Next

        Catch ex As Exception
            MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Connection Error !!")
        End Try
        con.Close()
    End Sub

Edited 5 Years Ago by Jx_Man: n/a

yes i using oOleDbConnectio

Dim conn As New OleDbConnection("provider=microsoft.jet.oleDB.4.0;Data Source=" & Application.StartupPath & "\mydatabase.mdb")

still not work...do i need to add database using add new source

application.StartupPath refers to debug folder..
what the result of your startup execution?
if you feel hard to use application.startup then write your current address manually.
ex :

con.ConnectionString = ("Provider = Microsoft.JET.OLEDB.4.0;Data Source=C:\Documents and Settings\Ichigo\My Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\bin\Debug\mydatabase.mdb")

Edited 5 Years Ago by Jx_Man: n/a

This article has been dead for over six months. Start a new discussion instead.