P
psychomad
Please, can someone help me out to solve this error, i've been
searching throughout my codes and yet i didnt succeed in finding the
error!!!!
The Error is:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Data 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 19:
Line 20: oDA = New OleDbDataAdapter(sSql, oConn)
Line 21: oDA.Fill(oDS, "product")
Line 22: txtProduct_Number.Text =
oDS.Tables("product").Rows(0).Item("Product_Number")
Line 23: txtProduct_Type.Text =
oDS.Tables("product").Rows(0).Item("Product_Type")
Source File: c:\inetpub\wwwroot\bhavish\products_update.aspx Line:
21
Here is my codes:
_______________________________________________________________________________
<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb"%>
<script language="VB" runat=server>
Dim oConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.
4.0;Data Source=C:\bhavish_vb_asign\StoresDbs.mdb")
Dim strProduct_Number, strProduct_Type, strProduct,
strProduct_Details, strPrice, strPhoto as string
Sub Insert_Click(ByVal Src As Object, ByVal E As EventArgs)
Dim oDA As OleDbDataAdapter
Dim oDS As New DataSet
Dim sSql As String
oConn.Open()
sSql = "UPDATE product SET Product_Type = '" &
txtProduct_Type.text & "', Product = '" & txtproduct.text & "',
Product_Details = '" & txtProduct_Details.text & "', Price = '" &
txtPrice.text & "', Photo = '" & txtPhoto.text & "' WHERE
Product_Number = '" & txtProduct_Number.Text & "' "
oDA = New OleDbDataAdapter(sSql, oConn)
oDA.Fill(oDS, "product")
txtProduct_Number.Text =
oDS.Tables("product").Rows(0).Item("Product_Number")
txtProduct_Type.Text =
oDS.Tables("product").Rows(0).Item("Product_Type")
txtProduct.Text =
oDS.Tables("product").Rows(0).Item("Product")
txtProduct_Details.Text =
oDS.Tables("product").Rows(0).Item("Product_Details")
txtPrice.Text = oDS.Tables("product").Rows(0).Item("Price")
txtPhoto.Text = oDS.Tables("product").Rows(0).Item("Photo")
End Sub
Private Function update(ByVal oConn As OleDbConnection, ByVal
strInsertSQL As String) As Integer
Dim intQueryState As Integer
' Connect to Database
oConn.Open()
'Make the OleDbCommand object
Dim cmdInsert As New OleDbCommand(strInsertSQL, oConn)
intQueryState = cmdInsert.ExecuteNonQuery()
oConn.Close()
Return intQueryState
End Function
Private Function Exists(ByVal oConn As OleDbConnection, ByVal
Value As String, ByVal ValueColumn As String, ByVal Item As String,
ByVal ItemColumn As String, ByVal TableName As String, Optional ByVal
bIsNumeric As Boolean = False) As Integer
Dim blnUserAuthenticated As Boolean = False
' Connect to Database
Dim strSQL As String = "Select * from " & TableName & "
where " & ItemColumn & "='" & Item & "' AND " & ValueColumn & "=" &
IIf(bIsNumeric, Value, "'" & Value & "'")
Dim cmd As New OleDbCommand(strSQL, oConn)
Dim objDataReader As OleDbDataReader
objDataReader = cmd.ExecuteReader()
oConn.Close()
End Function
</script>
_______________________________________________________________________________
searching throughout my codes and yet i didnt succeed in finding the
error!!!!
The Error is:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Data 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 19:
Line 20: oDA = New OleDbDataAdapter(sSql, oConn)
Line 21: oDA.Fill(oDS, "product")
Line 22: txtProduct_Number.Text =
oDS.Tables("product").Rows(0).Item("Product_Number")
Line 23: txtProduct_Type.Text =
oDS.Tables("product").Rows(0).Item("Product_Type")
Source File: c:\inetpub\wwwroot\bhavish\products_update.aspx Line:
21
Here is my codes:
_______________________________________________________________________________
<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb"%>
<script language="VB" runat=server>
Dim oConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.
4.0;Data Source=C:\bhavish_vb_asign\StoresDbs.mdb")
Dim strProduct_Number, strProduct_Type, strProduct,
strProduct_Details, strPrice, strPhoto as string
Sub Insert_Click(ByVal Src As Object, ByVal E As EventArgs)
Dim oDA As OleDbDataAdapter
Dim oDS As New DataSet
Dim sSql As String
oConn.Open()
sSql = "UPDATE product SET Product_Type = '" &
txtProduct_Type.text & "', Product = '" & txtproduct.text & "',
Product_Details = '" & txtProduct_Details.text & "', Price = '" &
txtPrice.text & "', Photo = '" & txtPhoto.text & "' WHERE
Product_Number = '" & txtProduct_Number.Text & "' "
oDA = New OleDbDataAdapter(sSql, oConn)
oDA.Fill(oDS, "product")
txtProduct_Number.Text =
oDS.Tables("product").Rows(0).Item("Product_Number")
txtProduct_Type.Text =
oDS.Tables("product").Rows(0).Item("Product_Type")
txtProduct.Text =
oDS.Tables("product").Rows(0).Item("Product")
txtProduct_Details.Text =
oDS.Tables("product").Rows(0).Item("Product_Details")
txtPrice.Text = oDS.Tables("product").Rows(0).Item("Price")
txtPhoto.Text = oDS.Tables("product").Rows(0).Item("Photo")
End Sub
Private Function update(ByVal oConn As OleDbConnection, ByVal
strInsertSQL As String) As Integer
Dim intQueryState As Integer
' Connect to Database
oConn.Open()
'Make the OleDbCommand object
Dim cmdInsert As New OleDbCommand(strInsertSQL, oConn)
intQueryState = cmdInsert.ExecuteNonQuery()
oConn.Close()
Return intQueryState
End Function
Private Function Exists(ByVal oConn As OleDbConnection, ByVal
Value As String, ByVal ValueColumn As String, ByVal Item As String,
ByVal ItemColumn As String, ByVal TableName As String, Optional ByVal
bIsNumeric As Boolean = False) As Integer
Dim blnUserAuthenticated As Boolean = False
' Connect to Database
Dim strSQL As String = "Select * from " & TableName & "
where " & ItemColumn & "='" & Item & "' AND " & ValueColumn & "=" &
IIf(bIsNumeric, Value, "'" & Value & "'")
Dim cmd As New OleDbCommand(strSQL, oConn)
Dim objDataReader As OleDbDataReader
objDataReader = cmd.ExecuteReader()
oConn.Close()
End Function
</script>
_______________________________________________________________________________