Retroceder   Foros del Web > Programación para sitios web > .NET

Respuesta
 
Herramientas Desplegado
Antiguo 08-mar-2007, 08:45   #1 (permalink)
lisseth ha deshabilitado el karma
 
Fecha de Ingreso: enero-2007
Mensajes: 78
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("mail@dominio.com", "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.
lisseth está desconectado   Responder Citando
Antiguo 16-mar-2007, 10:45   #2 (permalink)
reel está en el buen camino
 
Avatar de reel
 
Fecha de Ingreso: febrero-2004
Ubicación: Managua, Nicaragua
Mensajes: 481
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.
reel está desconectado   Responder Citando
Respuesta

No hay votos aún.


Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder temas
No puedes subir archivos adjuntos
No puedes editar tus mensajes

BB code is Activado
Caritas están Activado
[IMG] está Activado
Código HTML está Desactivado


La Zona horaria es GMT -6. Ahora son las 19:41.


Message Board Statistics

LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93