Actually I'm using ds everywere but I tryed to change it
here to better describe what I was doing (I missed that
last one). However I am useing a variable ds everywhere
which is a type dataset.
DBVar is global connection to the access database.Its used
as follows.
Public DBvar As New ADODB.Connection()
DBvar.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=PalData.mdb")
Is the connection the problem? How do I need to change it
to get it to work with datagrids? Do I need any special
references?
Thanks,
-----Original Message-----
"Sebastian" <Se*******@ilogic.com> schrieb I'm trying to connect a query I made in the Access
database to populate a grid.I'm using the following code
and I get a error:
Specified cast is not valid.
on the first line below. Any Ideas?
Dim DataAdp As OleDbDataAdapter = New OleDbDataAdapter
("GetInvoices", DBvar)
I've no clue, but.. what is the type of DBVar? It must
be a string or anSystem.Data.OleDb.OleDbConnection.
DataAdp.SelectCommand.CommandType =
CommandType.StoredProcedure
If Not IsDBNull(DataAdp) Then
Using IsDBNull on a DataAdapter doesn't make sense at
all. A DataAdapter isan object reading and storing records from and into a
database.
Try
DataAdp.Fill(ds, "Invoices")
Catch ex As Exception
MsgBox(ex.Message,
MsgBoxStyle.Critical, "Error:")
End Try
GrdInvoices.DataSource = dataset.Tables
("Invoices")
You are reading into "ds", but
attaching "dataset"(.tables)? End If
ts.MappingName = dataset.Tables
("Invoices").TableName
--
Armin
How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
.