473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Missing required parameter error

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

Feb 20 '06 #1
1 1620
add
myCommand.CommandType = CommandType.Text
before the execute.

Regards,

Trevor Benedict R
MCSD

"Damon" <ko**@redshift.com> wrote in message
news:11*********************@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

Feb 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kalpana.sinduria | last post by:
Hi all, how to remove the following complle error. When I compiling the code I get the following errors: Compiling... CDrtEachDefFeat.cpp d:\ include\common\cdrtintegfeat.h(39) : error...
4
by: dcarson | last post by:
I've read about this error in several other discussions, but still can't seem to pinpoint the problem with my code. Everything seemed to be working fine for some time, but it now tends to bomb out...
3
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I...
2
by: inventor | last post by:
I'm doing programming for my science prodject, and when I was programming (I'm building an alphebatizer) I ran into this bug: I've got an input box, but no button or output box. so I do some...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.