Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

ayuda en vb.0 y sql server 2000

Estas en el tema de ayuda en vb.0 y sql server 2000 en el foro de Visual Basic clásico en Foros del Web. saludos mis panas gracias primero q todo por q este foro me ja sido de gran ayuda ya q me estoy iniciando en la programacion ...
  #1 (permalink)  
Antiguo 05/08/2010, 13:14
 
Fecha de Ingreso: junio-2010
Ubicación: maracaibo
Mensajes: 40
Antigüedad: 13 años, 9 meses
Puntos: 0
Mensaje ayuda en vb.0 y sql server 2000

saludos mis panas gracias primero q todo por q este foro me ja sido de gran ayuda ya q me estoy iniciando en la programacion


mi problema es:
estoy trabajando con una aplicacion q hace una consulta en sql server 2000
en esta aplicacion realizo mis busqdas por descripcio, marca, existencia y precio que tiene un rango de pvpdesde hasta pvphasta ejemplo desde 10 hasta 100

pero cuando estos texbox (txtPVPdesde) y (txtPVPhasta) cuando uno de los 2 esta vacio y ejecuto la consulta se produce un error en tiempo de ejecucion y se cierra la aplicacion.

habra una manera de como arreglar ese error y salga un msj de aviso q diga
introdusca un monto y evite q la aplicacion se cierre este es el codigo de toda la aplicacion.

Option Explicit
Dim cnConexionBD As ADODB.Connection
Dim rsConexion As ADODB.Recordset
Dim strSQL As String
Dim strCodigo As String
Dim strDescripcion As String
Dim strMarca As String
Dim strObservaciones As String
'Dim strUbicaciondeFoto As String

Private Sub cmdConsultar_Click()
Set cnConexionBD = New ADODB.Connection
cnConexionBD.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;" & _
"Initial Catalog=dbMundoSQL;Data Source=SERVMUNDO"
cnConexionBD.CursorLocation = adUseClient
cnConexionBD.Open
''''''''''''''''''''''''''''''''''''''''''
strDescripcion = txtDescripcion.Text 'VA
strMarca = txtMarca.Text ' RIA
strObservaciones = txtObservaciones.Text ' BLE
strCodigo = txtCodigo.Text ' S
''''''''''''''''''''''''''''''''''''''''''
strSQL = "SELECT PrecioDetal * 1.12 AS PVP, tblProduct.CodRef, tblProduct.Descripcion, " & _
"tblProduct.Marca, tblExistencia.Existencia, tblProduct.IDUnidC , tblExistencia.Observaciones, UbicaFoto" & _
" FROM tblProduct " & _
"INNER JOIN tblExistencia ON tblProduct.CodRef = tblExistencia.CodRef " & _
"WHERE (Descripcion LIKE '%" & strDescripcion & "%' ) AND (Marca LIKE '%" & strMarca & "%') AND " & _
"(tblProduct.CodRef LIKE '%" & strCodigo & "%') AND (Observaciones LIKE '%" & strObservaciones & "%') " & _
"AND ((PrecioDetal * 1.12) BETWEEN " & txtPVPdesde.Text & " AND " & txtPVPhasta.Text & ") "
If OptCodigo.Value = True Then
strSQL = strSQL & "ORDER BY tblProduct.CodRef"
End If
If OptDescripcion.Value = True Then
strSQL = strSQL & "ORDER BY Descripcion"
End If
If OptMarca.Value = True Then
strSQL = strSQL & "ORDER BY Marca"
End If
If OptPVP.Value = True Then
strSQL = strSQL & "ORDER BY PVP"
End If
If OptObservaciones.Value = True Then
strSQL = strSQL & "ORDER BY Observaciones"
End If
If optExistencia.Value = True Then
strSQL = strSQL & "ORDER BY Existencia"
End If
Set rsConexion = cnConexionBD.Execute(strSQL)
If rsConexion.RecordCount > 0 Then
Set dgrConsulta.DataSource = rsConexion
dgrConsulta.Visible = True
dgrConsulta.Columns(0).Width = 1000 'Ancho columna PVP
dgrConsulta.Columns(0).Locked = True
dgrConsulta.Columns(0).NumberFormat = "#,##0.00" ' formato a la columna PVP
dgrConsulta.Columns(1).Width = 1300 'Ancho columnas Codigo
dgrConsulta.Columns(2).Width = 3500 'Ancho columna Descripcion
dgrConsulta.Columns(3).Width = 1500 'Ancho columnas Marca
dgrConsulta.Columns(4).Width = 800 'Ancho columnas Existencia
dgrConsulta.Columns(5).Width = 800 'Ancho columnas Unidades
dgrConsulta.Columns(6).Width = 4000 'Ancho columnas Observaciones
dgrConsulta.Columns(7).Visible = False 'COLUMNA DE DIRECCION DE FOTOS
cmdRefrescar.Enabled = True
Else
MsgBox "No Hay Existencia del Producto", vbInformation
Set dgrConsulta.DataSource = rsConexion
dgrConsulta.Visible = False
End If
txtTotalRegistros.Text = rsConexion.RecordCount
End Sub

Private Sub cmdRefrescar_Click()
cnConexionBD.Close
dgrConsulta.Visible = False
cmdRefrescar.Enabled = False
txtTotalRegistros.Text = ""
txtCodigo.Text = ""
txtDescripcion.Text = ""
txtMarca.Text = ""
txtObservaciones.Text = ""
txtPVPdesde.Text = "0.01"
txtPVPhasta.Text = "1000"
txtCodigo.SetFocus
End Sub

Private Sub cmdSalir_Click()
End
End Sub

Private Sub dgrConsulta_DblClick()
If dgrConsulta.Columns(7).Value = rsConexion!UbicaFoto Then
imgFotoProducto.Picture = LoadPicture(rsConexion!UbicaFoto)
Else: imgFotoProducto.Picture = LoadPicture("C:\SAT\Pictures\SinFoto.Bmp")
End If
End Sub

Private Sub OptCodigo_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdConsultar_Click
End If
End Sub

Private Sub OptDescripcion_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdConsultar_Click
End If
End Sub

Private Sub optExistencia_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdConsultar_Click
End If
End Sub

Private Sub OptMarca_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdConsultar_Click
End If
End Sub

Private Sub OptObservaciones_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdConsultar_Click
End If
End Sub

Private Sub OptPVP_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdConsultar_Click
End If
End Sub

Private Sub txtCodigo_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdConsultar_Click
End If
End Sub

Private Sub txtDescripcion_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdConsultar_Click
End If
End Sub

Private Sub txtMarca_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdConsultar_Click
End If
End Sub

Private Sub txtObservaciones_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdConsultar_Click
End If
End Sub

Private Sub txtPVPdesde_KeyPress(KeyAscii As Integer)
If KeyAscii = Asc(",") Then
KeyAscii = Asc(".")
End If
If InStr(1, "0123456789.", Chr(KeyAscii)) = 0 And KeyAscii <> vbKeyBack And KeyAscii <> vbKeyReturn Then
KeyAscii = 0
MsgBox "Tipo de Caractér no permitido"
End If
If KeyAscii = 13 Then
Call cmdConsultar_Click
End If
End Sub

Private Sub txtPVPhasta_KeyPress(KeyAscii As Integer)
If KeyAscii = Asc(",") Then
KeyAscii = Asc(".")
End If
If InStr(1, "0123456789.", Chr(KeyAscii)) = 0 And KeyAscii <> vbKeyBack And KeyAscii <> vbKeyReturn Then
KeyAscii = 0
MsgBox "Tipo de Caractér no permitido"
End If
If KeyAscii = 13 Then
Call cmdConsultar_Click
End If
End Sub
  #2 (permalink)  
Antiguo 10/08/2010, 14:02
Avatar de hugo180486  
Fecha de Ingreso: septiembre-2007
Mensajes: 199
Antigüedad: 16 años, 7 meses
Puntos: 3
Respuesta: ayuda en vb.0 y sql server 2000

If
Código vb:
Ver original
  1. if  txtPVPdesde.Value = "" OR txtPVPhasta.Value = "" Then
  2. MsgBOx "Debes llenar todos los TEXTBOX" '// Aqui pones lo que se te ocurra
  3. Else
  4. '// Todo tu codigo, el de la consulta...
  5. End if

Etiquetas: server, sql, vb
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 10:48.