P
Patrick Sullivan
I decided to try using relations and untyped datasets for syncing a datagrid
(child records)with a combobox (parent rows). Also put in stuff I thought I
needed to set up dataviews for filtering. Now the ds won't load objects
(tables) it seems like. I took out the tablemappings and schema actions for
a while but it still had the same problem. No errors from SQL Server.
Profiler says SET FMTONLY OFF; SET NO_BROWSETABLE ON;SELECT * FROM Contacts
SET NO_BROWSETABLE OFF; and SET FMTONLY OFF; SET NO_BROWSETABLE ON;SELECT *
FROM Companies order by compName SET NO_BROWSETABLE OFF; What does all that
mean?? TIA
Private Sub LoadData()
Dim conn As New SqlConnection(ConnectionString)
Dim selectCommand1 As String = "SELECT * FROM Companies order by
compName"
Dim compAdapter As New SqlDataAdapter(selectCommand1, conn)
Dim selectCommand2 As String = "SELECT * FROM Contacts"
Dim contAdapter As New SqlDataAdapter(selectCommand2, conn)
compAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
compAdapter.TableMappings.Add("Tables", "Companies")
contAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
contAdapter.TableMappings.Add("Table", "Contacts")
Try
compAdapter.Fill(ds)
contAdapter.Fill(ds)
conn.Close()
Catch exc As Exception
' Unable to connect to SQL Server
MessageBox.Show(exc.Message, "Error in LoadData()",
MsgBoxStyle.Critical)
End
End Try
DVCompanies.Table = ds.Tables("Companies")
An unhandled exception of type 'System.NullReferenceException' occurred
Additional information: Object reference not set to an instance of an
object.
DVContacts.Table = ds.Tables("Contacts")
DVContacts.RowFilter = "compID=-1"
With ds
.Relations.Add("FK_companyContacts", _
.Tables("Companies").Columns("compID"), _
.Tables("Contacts").Columns("contactCompany"), False)
End With
End Sub
(child records)with a combobox (parent rows). Also put in stuff I thought I
needed to set up dataviews for filtering. Now the ds won't load objects
(tables) it seems like. I took out the tablemappings and schema actions for
a while but it still had the same problem. No errors from SQL Server.
Profiler says SET FMTONLY OFF; SET NO_BROWSETABLE ON;SELECT * FROM Contacts
SET NO_BROWSETABLE OFF; and SET FMTONLY OFF; SET NO_BROWSETABLE ON;SELECT *
FROM Companies order by compName SET NO_BROWSETABLE OFF; What does all that
mean?? TIA
Private Sub LoadData()
Dim conn As New SqlConnection(ConnectionString)
Dim selectCommand1 As String = "SELECT * FROM Companies order by
compName"
Dim compAdapter As New SqlDataAdapter(selectCommand1, conn)
Dim selectCommand2 As String = "SELECT * FROM Contacts"
Dim contAdapter As New SqlDataAdapter(selectCommand2, conn)
compAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
compAdapter.TableMappings.Add("Tables", "Companies")
contAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
contAdapter.TableMappings.Add("Table", "Contacts")
Try
compAdapter.Fill(ds)
contAdapter.Fill(ds)
conn.Close()
Catch exc As Exception
' Unable to connect to SQL Server
MessageBox.Show(exc.Message, "Error in LoadData()",
MsgBoxStyle.Critical)
End
End Try
DVCompanies.Table = ds.Tables("Companies")
An unhandled exception of type 'System.NullReferenceException' occurred
Additional information: Object reference not set to an instance of an
object.
DVContacts.Table = ds.Tables("Contacts")
DVContacts.RowFilter = "compID=-1"
With ds
.Relations.Add("FK_companyContacts", _
.Tables("Companies").Columns("compID"), _
.Tables("Contacts").Columns("contactCompany"), False)
End With
End Sub