Binding Datagrid to SQLCE DB

S

Scott Toney

I have the following code that "seems" to work but a portion of "Header
column 1" and Row Header 1 with a black arrow pointing right. If anyone has
any information it will be greatly appreciated.

Scott
Private Sub LoadApptList()
Dim cn As System.Data.SqlServerCe.SqlCeConnection
Dim cmd As System.Data.SqlServerCe.SqlCeCommand
'Dim dtr As System.Data.SqlServerCe.SqlCeDataReader
Dim SQL As String
Dim ds As System.Data.DataSet
Dim da As System.Data.SqlServerCe.SqlCeDataAdapter

Try
' Open the database.
cn = New System.Data.SqlServerCe.SqlCeConnection("Data
Source=\My Documents\Appt.sdf")
cn.Open()

' Retrieve the appointments
SQL = "SELECT Appt.ApptID, Appt.CustID, "
SQL = SQL & "Cust.CustName, Appt.Time "
SQL = SQL & "FROM Appt INNER JOIN Cust ON "
SQL = SQL & "Appt.CustID = Cust.CustID WHERE "
SQL = SQL & "Appt.Show <> 'N'"
cmd = New System.Data.SqlServerCe.SqlCeCommand(SQL, cn)
'dtr = cmd.ExecuteReader()

ds = New DataSet
da = New SqlServerCe.SqlCeDataAdapter
da.SelectCommand = cmd
da.SelectCommand.Connection = cn
da.Fill(ds)
ApptGrid.DataSource = ds
MessageBox.Show(CStr(ApptGrid.VisibleRowCount))
ApptGrid.ColumnHeadersVisible = True
'ApptGrid.BringToFront()
'ApptGrid.DataSource = dtr


Catch sqex As System.Data.SqlServerCe.SqlCeException
MessageBox.Show(sqex.ToString(), "DB operation failed")
Catch er As Exception
MessageBox.Show(er.ToString)
End Try

' Clean-up.
'dtr.Close()
cn.Close()

End Sub
 
S

Scott Toney

Nevermind, found it. I changed the ds (dataset) to dt (datatable) and all is
well now.
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top