Foros del Web » Programación para mayores de 30 ;) » .NET »

Data type mismatch in criteria expression.

Estas en el tema de Data type mismatch in criteria expression. en el foro de .NET en Foros del Web. saludos, este es mi codigo: Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols, System.Data, System.Data.OleDb Imports System.Net.Mail Partial Class contacto_default Inherits System.Web.UI.Page Dim cn As New OleDbConnection ...
  #1 (permalink)  
Antiguo 08/03/2007, 09:45
 
Fecha de Ingreso: enero-2007
Mensajes: 80
Antigüedad: 17 años, 3 meses
Puntos: 0
Data type mismatch in criteria expression.

saludos,

este es mi codigo:

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols, System.Data, System.Data.OleDb
Imports System.Net.Mail

Partial Class contacto_default
Inherits System.Web.UI.Page

Dim cn As New OleDbConnection
Dim cmd As New OleDbCommand
Dim dr As OleDbDataReader
Dim var_cn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\prueba\App_Data\ejemplo. mdb;Persist Security Info=True"
Dim cod1 As String

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
cn.ConnectionString = var_cn
If cn.State = ConnectionState.Open Then
cn.Close()
End If
cn.Open()

With cmd
.Connection = cn
.CommandType = CommandType.Text
.CommandText = "SELECT user_id, user_mail FROM USER WHERE (user_id = '" & cod1 & "')"
dr = .ExecuteReader()
End With
If dr.Read Then
lbl_correo.Text = dr("user_mail")

Dim clientesSMTP As New SmtpClient
Dim mensaje As New MailMessage
Dim destino As String = lbl_correo.Text.ToString
Try
Dim de As New MailAddress("[email protected]", "Prueba")
clientesSMTP.Host = "localhost"
clientesSMTP.Port = 25
mensaje.From = de
mensaje.To.Add(destino)
mensaje.Subject = "Ha sido enviado el siguiente formulario"
mensaje.IsBodyHtml = True
mensaje.Body = "<p>Los datos son los siguientes:Nombre:</p>" & txt_nombre.Text.ToString & "<br />Direccion:" & txt_dir.Text.ToString & "<br />Telefono:" & txt_telf.Text.ToString & "<br />Correo:" & txt_correo.Text.ToString & "<br />Codigo:" & txt_codigo.Text.ToString & "</p>"
clientesSMTP.Send(mensaje)
Catch ex As Exception
Me.lbl_error.Text = ex.Message
End Try
End If

End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack = True Then
cod1 = Me.txt_codigo.Text
End If
End Sub
End Class

al momento de presionar el boton enviar me sale este mensaje de error:


Server Error in '/prueba' 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 24: .CommandType = CommandType.Text
Line 25: .CommandText = "SELECT user_id, user_mail FROM DISTRIBUIDOR WHERE (user_id = '" & cod1 & "')"
Line 26: dr = .ExecuteReader()
Line 27: End With
Line 28: If dr.Read Then


Source File: c:\inetpub\wwwroot\prueba\contacto\default.aspx.vb Line: 26

Stack Trace:


[OleDbException (0x80040e07): Data type mismatch in criteria expression.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult) +267
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) +192
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult) +48
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method) +106
System.Data.OleDb.OleDbCommand.ExecuteReader(Comma ndBehavior behavior) +111
System.Data.OleDb.OleDbCommand.ExecuteReader() +6
contacto_default.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\herbalife\contacto\default.aspx .vb:26
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

si alguien tien alguna idea de la causa y la solucion de este error desde ya muchas gracias.
  #2 (permalink)  
Antiguo 16/03/2007, 10:45
Avatar de reel  
Fecha de Ingreso: febrero-2004
Ubicación: Managua, Nicaragua
Mensajes: 496
Antigüedad: 20 años, 2 meses
Puntos: 1
Re: Data type mismatch in criteria expression.

Al parecer el problema esta en la consulta que mandas a ejecutar, porque no purebas depurar la cadena SQL que estás formando.

Saludes,
__________________
Leer es Saber, REEL.
Mi Blog
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:16.