|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Binding a combo boxI configured a data adapter and generated a dataset and wrote the code to
fill the dataset with data coming from an SQL database table when my form loads. I also changed the DataSource of a combo box to point to the dataset.tablename and changed the DisplayMemebr to point at a column. After the form loads nothing is populated in the combo box? Is there something I'm missing. Please help -- TS Hi,
Here is an example. Dim strConn As String Dim strSQL As String Dim ds As New DataSet Dim da As OleDbDataAdapter Dim conn As OleDbConnection strConn = "Provider = Microsoft.Jet.OLEDB.4.0;" strConn &= "Data Source = Northwind.mdb;" conn = New OleDbConnection(strConn) da = New OleDbDataAdapter("Select * From Categories", conn) da.Fill(ds, "Categories") ComboBox1.DataSource = ds.Tables("Categories") ComboBox1.DisplayMember = "Description" Ken -------------------------- "TS" <T*@discussions.microsoft.com> wrote in message I configured a data adapter and generated a dataset and wrote the code tonews:9A425555-253B-44E7-A354-B920CF75D580@microsoft.com... fill the dataset with data coming from an SQL database table when my form loads. I also changed the DataSource of a combo box to point to the dataset.tablename and changed the DisplayMemebr to point at a column. After the form loads nothing is populated in the combo box? Is there something I'm missing. Please help -- TS Thanks for your reply. I tried the code you sent me and it generated the
following error message: "Unhandled Exception: System.Data.OleDb.OleDbException: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. Here is the code: Dim strConn As String Dim strSQL As String Dim SscIntake1 As New DataSet() Dim da As OleDb.OleDbDataAdapter Dim conn As OleDb.OleDbConnection strConn = "Provider = Microsoft.Jet.OLEDB.4.0;" strConn &= "Data Source = Persist Security Info=true;Integrated Security=false;User ID=sa;Password=xxx;database=SSC;server=zzz;" conn = New OleDb.OleDbConnection(strConn) da = New OleDb.OleDbDataAdapter("Select * From qmf_cint", conn) da.Fill(SscIntake1, "qmf_cint") ComboBox1.DataSource = SscIntake1.Tables("qmf_cint") ComboBox1.DisplayMember = "Last_Name" Show quoteHide quote "Ken Tucker [MVP]" wrote: > Hi, > > Here is an example. > > Dim strConn As String > > Dim strSQL As String > > Dim ds As New DataSet > > Dim da As OleDbDataAdapter > > Dim conn As OleDbConnection > > strConn = "Provider = Microsoft.Jet.OLEDB.4.0;" > > strConn &= "Data Source = Northwind.mdb;" > > conn = New OleDbConnection(strConn) > > da = New OleDbDataAdapter("Select * From Categories", conn) > > da.Fill(ds, "Categories") > > ComboBox1.DataSource = ds.Tables("Categories") > > ComboBox1.DisplayMember = "Description" > > > > Ken > > -------------------------- > > "TS" <T*@discussions.microsoft.com> wrote in message > news:9A425555-253B-44E7-A354-B920CF75D580@microsoft.com... > I configured a data adapter and generated a dataset and wrote the code to > fill the dataset with data coming from an SQL database table when my form > loads. I also changed the DataSource of a combo box to point to the > dataset.tablename and changed the DisplayMemebr to point at a column. After > the form loads nothing is populated in the combo box? Is there something I'm > missing. Please help > -- > TS > > > TS,
Show a little piece of code, (first without the designer part). (And please first pasted in a notebook and copied back to make it readable) (I assume that you bind in the desiger and that you told in that wich *datatable*, often is the wrong point taken to do that, so you can check that first) Cor
Opening Forms.
sorting files retrieved by OpenFileDialog Total seconds of day VB.Net Joining Paradox and SQL Server Table? MDI Child Form ? Using Comm dll file in vb.net 2003 error Insert Border around a picture Who is logged on Win2003 Server? Newbie; datagrid and Excel questions Resize Tab control when windows form resizes |
|||||||||||||||||||||||