Hi all,

I am using MsAccess as my database in ASp.net and VB.NET for codeing and i am trying to pass some parameters into access to execute the query but it come up with the error "Data type mismatch in criteria expression".

i have give the code and the Query I am using

Dim strUserName As String = Replace(Session("UserDetails").UserName, "'", "''", 1)
Dim intUserID As Integer = Replace(Session("UserDetails").ID, "'", "''", 1)
Dim mcDB As New clsDBQueries(ConfigurationSettings.AppSettings.Get("ConnectionString"))
Dim newCustomerID As Long
newCustomerID = mcDB.GetNextID("tblCustomers", "fldCustomer")
Try

Dim ParameterArray(7) As OleDbParameter
ParameterArray(0) = New OleDbParameter("@CustomerID", newCustomerID)
ParameterArray(1) = New OleDbParameter("@Code", CStr(100000 + newCustomerID))
ParameterArray(2) = New OleDbParameter("@CreatedBy", strUserName)
ParameterArray(3) = New OleDbParameter("@CreatedOn", Now.ToOADate)
ParameterArray(4) = New OleDbParameter("@CreatedByID", intUserID)
ParameterArray(5) = New OleDbParameter("@ManagedBy", strUserName)
ParameterArray(6) = New OleDbParameter("@ManagedBYID", intUserID)
ParameterArray(7) = New OleDbParameter("@OldCustomerID", CInt(Session("CustomerID")))
mcDB.ExecuteStoredProcedure("qryRenewalCustomer", ParameterArray)


'seperate function to execute the query

Dim p As OleDbParameter
For Each p In commandParameters
'check for derived output value with no value assigned
If p.Direction = ParameterDirection.InputOutput And p.Value Is Nothing Then
p.Value = DBNull.Value
End If
cmd.Parameters.Add(p)
Next p
ExecuteCommand(cmd)


' the Query in the database.

PARAMETERS [@CustomerID] Long, [@code] Text ( 255 ), [@CreatedBy] Text ( 255 ), [@CreatedOn] IEEEDouble, [@CreatedByID] Long, [@ManagedBy] Text ( 255 ), [@ManagedBYID] Long, [@OldCustomerID] Long;
INSERT INTO tblCustomers ( fldCustomer, fldDel, fldReseller, fldBSS, fldDIG, fldAAV, fldCompany, fldCode, fldTitle, fldName, fldSurname, fldMailing, fldDeAddress, fldDeTown, fldDeCounty, fldDeCountry, fldDePostCode, fldMaAddress, fldMaTown, fldMaCounty, fldMaCountry, fldMaPostCode, fldPhoneOneArea, fldPhoneOne, fldPhoneTwoArea, fldPhoneTwo, fldWorkPhoneArea, fldWorkPhone, fldFaxArea, fldFax, fldMobile, fldeMail, fldWeb, fldNotes, fldInstallDate, fldInstallCompleteDate, fldInstallNotes, fldCreatedBy, fldEditedBy, fldCreatedOn, fldCreatedByID, fldEditedByID, fldManagedBy, fldManagedByID, fldDeletedOn, fldDeletedBy, fldDeletedID, fldOldID )
SELECT [@CustomerID] AS Customer, tblCustomers.fldDel, tblCustomers.fldReseller, tblCustomers.fldBSS, tblCustomers.fldDIG, tblCustomers.fldAAV, tblCustomers.fldCompany, [@Code] AS Codein, tblCustomers.fldTitle, tblCustomers.fldName, tblCustomers.fldSurname, tblCustomers.fldMailing, tblCustomers.fldDeAddress, tblCustomers.fldDeTown, tblCustomers.fldDeCounty, tblCustomers.fldDeCountry, tblCustomers.fldDePostCode, tblCustomers.fldMaAddress, tblCustomers.fldMaTown, tblCustomers.fldMaCounty, tblCustomers.fldMaCountry, tblCustomers.fldMaPostCode, tblCustomers.fldPhoneOneArea, tblCustomers.fldPhoneOne, tblCustomers.fldPhoneTwoArea, tblCustomers.fldPhoneTwo, tblCustomers.fldWorkPhoneArea, tblCustomers.fldWorkPhone, tblCustomers.fldFaxArea, tblCustomers.fldFax, tblCustomers.fldMobile, tblCustomers.fldeMail, tblCustomers.fldWeb, tblCustomers.fldNotes, tblCustomers.fldInstallDate, tblCustomers.fldInstallCompleteDate, tblCustomers.fldInstallNotes, [@CreatedBy] AS CreatedByName, "" AS EditedBY, [@CreatedOn] AS CreatedOndate, [@CreatedByID] AS CreatedBynumb, "" AS EditedByID, [@ManagedBy] AS ManagedByName, [@ManagedByID] AS ManagedByNumb, Null AS DeletedON, Null AS DeletedBy, Null AS DeletedID, tblCustomers.fldCustomer
FROM tblCustomers
WHERE (((tblCustomers.fldCustomer)=[@OldCustomerID]));


i tried changing the datatypes but still it dosen't work.
any solution plaese let me know.