ralphtrent
Programmer
Hello
I would like to build a connection class and fill my data sets in the same class, then I would like to bind the datagrid in the form code. What I have does not work I get an error, stated below.
Here is my code:
Class db06302004
Dim objConn As SqlConnection = New SqlConnection("server=ereplandemoas3;database=FacetsSS;user id=FacetsSS;password=FacetsSS")
Dim objDataAdapter As SqlDataAdapter = New SqlDataAdapter
Public objDataSet As DataSet = New DataSet
Private Sub ConnOpen()
objConn.Open()
End Sub
Private Sub ConnClose()
objConn.Close()
End Sub
Public Sub FillDataSet()
Dim objDataAdapter = New SqlDataAdapter
objDataAdapter.SelectCommand = New SqlCommand
With objDataAdapter.SelectCommand
.CommandText = "Select * From FSS_USERS"
.Connection = objConn
.CommandType = CommandType.Text
End With
ConnOpen()
Dim objDataSet As DataSet = New DataSet
objDataAdapter.Fill(objDataSet, "Users")
ConnClose()
End Sub
End Class
I have this in the forms load event:
Dim Connection As New db06302004
Call Connection.FillDataSet()
DataGrid1.DataSource = Connection.objDataSet
DataGrid1.DataMember = "Users" ' I get this error " Cannot create a child list for field Users."
TextBox1.Text = Connection.objDataSet.GetXml
What am I doing wrong?
I would like to build a connection class and fill my data sets in the same class, then I would like to bind the datagrid in the form code. What I have does not work I get an error, stated below.
Here is my code:
Class db06302004
Dim objConn As SqlConnection = New SqlConnection("server=ereplandemoas3;database=FacetsSS;user id=FacetsSS;password=FacetsSS")
Dim objDataAdapter As SqlDataAdapter = New SqlDataAdapter
Public objDataSet As DataSet = New DataSet
Private Sub ConnOpen()
objConn.Open()
End Sub
Private Sub ConnClose()
objConn.Close()
End Sub
Public Sub FillDataSet()
Dim objDataAdapter = New SqlDataAdapter
objDataAdapter.SelectCommand = New SqlCommand
With objDataAdapter.SelectCommand
.CommandText = "Select * From FSS_USERS"
.Connection = objConn
.CommandType = CommandType.Text
End With
ConnOpen()
Dim objDataSet As DataSet = New DataSet
objDataAdapter.Fill(objDataSet, "Users")
ConnClose()
End Sub
End Class
I have this in the forms load event:
Dim Connection As New db06302004
Call Connection.FillDataSet()
DataGrid1.DataSource = Connection.objDataSet
DataGrid1.DataMember = "Users" ' I get this error " Cannot create a child list for field Users."
TextBox1.Text = Connection.objDataSet.GetXml
What am I doing wrong?