Hi all. I am very new to binding data to controls (namely a datagrid) but am trying to learn. I am using VS2003 (VB). I thought I had a grasp of it but kept getting
An unhandled exception of type System.Data.OleDb.OleDbException occurred in system.data.dll
OR
An unhandled exception of type System.Data.SqlClient.SqlException occurred in system.data.dll
depending what I try. I decided to start from scratch and do some tutorials. Here are some I have tried/downloaded and I keep getting the SAME errors:
http://msdn.microsoft.com/library/d...gdatainwindowsformusingparameterizedquery.asp
http://samples.gotdotnet.com/quickstart/winforms/doc/WinFormsData.aspx
Plus about 4 others I cant re-find again.
Obviously there is something wrong with a configuration I have set or maybe a bad file? Has anyone else had this issue when running tutorials on VS2003? What am I doing wrong? It seems to always error out on the Fill statement. Heres some examples of where its erroring:
and
Anyone have any ideas?
Jenn
An unhandled exception of type System.Data.OleDb.OleDbException occurred in system.data.dll
OR
An unhandled exception of type System.Data.SqlClient.SqlException occurred in system.data.dll
depending what I try. I decided to start from scratch and do some tutorials. Here are some I have tried/downloaded and I keep getting the SAME errors:
http://msdn.microsoft.com/library/d...gdatainwindowsformusingparameterizedquery.asp
http://samples.gotdotnet.com/quickstart/winforms/doc/WinFormsData.aspx
Plus about 4 others I cant re-find again.
Obviously there is something wrong with a configuration I have set or maybe a bad file? Has anyone else had this issue when running tutorials on VS2003? What am I doing wrong? It seems to always error out on the Fill statement. Heres some examples of where its erroring:
Code:
Dim data_adapter As SqlDataAdapter
Dim m_DataSet As DataSet
sSQL = "SELECT iManufacturerID FROM tManufacturers"
Create the SqlDataAdapter.
data_adapter = New SqlDataAdapter(sSQL, "Data Source=(local);Initial Catalog=xxx;User Id=xxx;Password=xxx")
Map Table to Contacts.
data_adapter.TableMappings.Add("Table", "Manufacturers")
Fill the DataSet.
m_DataSet = New DataSet
data_adapter.Fill(m_DataSet) ERRORING HERE!!!!!!!!!!!
Bind the DataGrid control to the Contacts DataTable.
dgOrder.DataSource = m_DataSet.Tables("Manufacturers")
and
Code:
Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click
The following line passes the value the user enter for state
to the SQL Select statement.
OleDbDataAdapter1.SelectCommand.Parameters("state").Value = txtStateParameter.Text
DsAuthors1.Clear()
OleDbDataAdapter1.Fill(DsAuthors1) ERRORING HERE!!!!!
ShowPosition()
End Sub
Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
Me.BindingContext(DsAuthors1, "authors").Position -= 1
ShowPosition()
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
Me.BindingContext(DsAuthors1, "authors").Position += 1
ShowPosition()
End Sub
Private Sub ShowPosition()
Dim iCnt As Integer
Dim iPos As Integer
iCnt = Me.BindingContext(DsAuthors1, "authors").Count
If iCnt = 0 Then
txtPosition.Text = "(No records)"
Else
iPos = Me.BindingContext(DsAuthors1, "authors").Position + 1
txtPosition.Text = iPos.ToString & " of " & iCnt.ToString
End If
End Sub
Anyone have any ideas?
Jenn