vicpal25
02-28-2006, 06:22 PM
Im a rookie at .net and I am trying to figure out why I keep on getting this one error in a return from this function called fetchReader coming from a fetch reader "<script language="C#" runat="server" src="fetchData_oledb.cs" />"
this is the function on the file (fetchData_oledb.cs):
OleDbDataReader fetchReader ( string query, string db ) {
// connect to data source
OleDbConnection myConn = new OleDbConnection (
"Provider=Microsoft.Jet.OleDb.4.0; Data Source=" +
Server.MapPath ( "~/access_db/" + db + ".mdb" ) );
// initialize command object with query
OleDbCommand myCmd = new OleDbCommand ( query, myConn );
// open connection
myConn.Open ( );
// return datareader
return myCmd.ExecuteReader ( CommandBehavior.CloseConnection );
}
and here is the code returning this function
<script language="C#" runat="server" src="fetchData_oledb.cs" />
<script runat="server">
void Page_Load ( Object src, EventArgs e ) {
// define the query
string query = "SELECT * FROM Employees where EmployeeID='" +
Request.QueryString [ "id" ] + "'";
// fetch reader and bind to a datalist
myData.DataSource = fetchReader ( query, "test" );
myData.DataBind ( );
}
</script>
I am getting this followign error:
ata type mismatch in criteria expression.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Data type mismatch in criteria expression.
Source Error:
Line 14:
Line 15: // return datareader
Line 16: return myCmd.ExecuteReader ( CommandBehavior.CloseConnection );
Line 17: }
Line 18:
this is the function on the file (fetchData_oledb.cs):
OleDbDataReader fetchReader ( string query, string db ) {
// connect to data source
OleDbConnection myConn = new OleDbConnection (
"Provider=Microsoft.Jet.OleDb.4.0; Data Source=" +
Server.MapPath ( "~/access_db/" + db + ".mdb" ) );
// initialize command object with query
OleDbCommand myCmd = new OleDbCommand ( query, myConn );
// open connection
myConn.Open ( );
// return datareader
return myCmd.ExecuteReader ( CommandBehavior.CloseConnection );
}
and here is the code returning this function
<script language="C#" runat="server" src="fetchData_oledb.cs" />
<script runat="server">
void Page_Load ( Object src, EventArgs e ) {
// define the query
string query = "SELECT * FROM Employees where EmployeeID='" +
Request.QueryString [ "id" ] + "'";
// fetch reader and bind to a datalist
myData.DataSource = fetchReader ( query, "test" );
myData.DataBind ( );
}
</script>
I am getting this followign error:
ata type mismatch in criteria expression.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Data type mismatch in criteria expression.
Source Error:
Line 14:
Line 15: // return datareader
Line 16: return myCmd.ExecuteReader ( CommandBehavior.CloseConnection );
Line 17: }
Line 18: