databinding error

J

John Smith

thanks for any help. I run a delete query on a datagrid which call a
databind method to update grids:

Exception Details: System.Data.OleDb.OleDbException: Not a valid file name.

Source Error:

Line 472: Dim ds As DataSet = New DataSet
Line 473: Dim Cmd As New OleDbDataAdapter(MySQL, MyConn)
Line 474: Cmd.Fill(ds, "Cleaning_Schedule")
Line 475: dgMonday.DataSource =
ds.Tables("Cleaning_Schedule").DefaultView()
Line 476: dgMonday.DataBind()


anyideas?
 
J

John Smith

thanks for any help. I run a delete query on a datagrid which call a
databind method to update grids:

Exception Details: System.Data.OleDb.OleDbException: Not a valid file name.

Source Error:

Line 472: Dim ds As DataSet = New DataSet
Line 473: Dim Cmd As New OleDbDataAdapter(MySQL, MyConn)
Line 474: Cmd.Fill(ds, "Cleaning_Schedule") - this is the highlighted
error
Line 475: dgMonday.DataSource =
ds.Tables("Cleaning_Schedule").DefaultView()
Line 476: dgMonday.DataBind()


anyideas?
 
J

Jason L James

John,

what is you SELECT statement? What is you connection string?

The invalid filename suggests connection string typo!

Jason.
 
J

John Smith

Sub BindData()

Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
"Data Source = c:\databases\database.mdb"

Dim MySQL As String = "Select * from Cleaning_Schedule Order by Task_id"

Dim MyConn As New OleDb.OleDbConnection(strConn)

Dim ds As DataSet = New DataSet

Dim Cmd As New OleDbDataAdapter(MySQL, MyConn)

Cmd.Fill(ds, "Monday_Schedule")

dgMonday.DataSource = ds.Tables("Monday_Schedule").DefaultView()

dgMonday.DataBind()

End Sub
 
J

John Smith

bump...anyone?
John Smith said:
Sub BindData()

Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
"Data Source = c:\databases\database.mdb"

Dim MySQL As String = "Select * from Cleaning_Schedule Order by Task_id"

Dim MyConn As New OleDb.OleDbConnection(strConn)

Dim ds As DataSet = New DataSet

Dim Cmd As New OleDbDataAdapter(MySQL, MyConn)

Cmd.Fill(ds, "Monday_Schedule")

dgMonday.DataSource = ds.Tables("Monday_Schedule").DefaultView()

dgMonday.DataBind()

End Sub
 
B

Beverley

Or maybe it's the fact that you have "Data Source=" twice. :) Didn't
notice that at first. Does it work if you change it to this?

Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\databases\database.mdb"
 
J

John Smith

yep already figured it out


cheers though
Beverley said:
Or maybe it's the fact that you have "Data Source=" twice. :) Didn't
notice that at first. Does it work if you change it to this?

Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\databases\database.mdb"
 
J

Jason L James

John, there are some typoes in this code:

Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source = c:\databases\database.mdb"

There were two Data Source entries in your line.

There is no command object in your code:

This should work fine.

Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source = c:\databases\database.mdb"
Dim MyConn As New OleDb.OleDbConnection(strConn)
Dim mySQL As String = "Select * from Cleaning_Schedule Order
by Task_id"
Dim myCmd As New OleDBCommand
myCmd.CommandText = mySQL
myCmd.Connection = MyConn
myCmd.CommandType = CommandType.Text
Dim myDA As New OleDBDataAdapter
myDA.SelectCommand = myCmd
Dim myDS As New DataSet
myDA.Fill(myDS)


Good luck and let us know how you get on.

Jason.
 

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