this still doesn't make any sense. I'm trying to run a select query on
an access database, and the query has NO parameters. And yet, I'm
still getting a "No value given for one or more required parameters"
error. What gives?
Here's my code. I put it in a Form_Load subroutine of a blank .aspx
page so that nothing else external would affect it. (And yes, the
Access database is meant to have a user name and password.)
Protected Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim myConnection As System.Data.OleDb.OleDbConnection
Dim connStr As String
connStr = String.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" & Server.MapPath(MyGlobals.ACCESS_DB) & "; " & _
"Persist Security Info=True; Jet
OLEDB:Engine Type=5; Jet OLEDB:System Database=" & _
MyGlobals.ACCESS_SYSTEM_MDW & "; User
ID=" & _
"XXXXX" & "; Password=" & _
"XXXXX")
myConnection = New System.Data.OleDb.OleDbConnection(connStr)
Dim mySelectQuery As String
Dim myCommand As New System.Data.OleDb.OleDbCommand()
mySelectQuery = "SELECT EmployeeID, LastName, FirstName,
EmpFileNumber " & _
"FROM employees"
myCommand = New System.Data.OleDb.OleDbCommand(mySelectQuery,
myConnection)
myConnection.Open()
Dim myReader As System.Data.OleDb.OleDbDataReader
myReader =
myCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
<-- error happens here
myConnection = Nothing
End Sub
Any ideas, anyone?
Damonadd
myCommand.CommandType = CommandType.Text
before the execute.
Regards,
Trevor Benedict R
MCSD
"Damon" <kowa@.redshift.com> wrote in message
news:1140469727.000825.71270@.g43g2000cwa.googlegro ups.com...
> I've distilled this down into the simplest possible code fragment and
> this still doesn't make any sense. I'm trying to run a select query on
> an access database, and the query has NO parameters. And yet, I'm
> still getting a "No value given for one or more required parameters"
> error. What gives?
> Here's my code. I put it in a Form_Load subroutine of a blank .aspx
> page so that nothing else external would affect it. (And yes, the
> Access database is meant to have a user name and password.)
> Protected Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs)
> Dim myConnection As System.Data.OleDb.OleDbConnection
> Dim connStr As String
> connStr = String.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data
> Source=" & Server.MapPath(MyGlobals.ACCESS_DB) & "; " & _
> "Persist Security Info=True; Jet
> OLEDB:Engine Type=5; Jet OLEDB:System Database=" & _
> MyGlobals.ACCESS_SYSTEM_MDW & "; User
> ID=" & _
> "XXXXX" & "; Password=" & _
> "XXXXX")
> myConnection = New System.Data.OleDb.OleDbConnection(connStr)
> Dim mySelectQuery As String
> Dim myCommand As New System.Data.OleDb.OleDbCommand()
> mySelectQuery = "SELECT EmployeeID, LastName, FirstName,
> EmpFileNumber " & _
> "FROM employees"
> myCommand = New System.Data.OleDb.OleDbCommand(mySelectQuery,
> myConnection)
> myConnection.Open()
> Dim myReader As System.Data.OleDb.OleDbDataReader
> myReader =
> myCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
> <-- error happens here
> myConnection = Nothing
> End Sub
> Any ideas, anyone?
> Damon
0 comments:
Post a Comment