
Error al convertir una cadena de caracteres en fecha y/u hora
Publicado por Brand (5 intervenciones) el 01/04/2016 20:07:41
Hola a todos, necesito una mano para solucionar este problema que tengo al tratar de guardar en la base de datos (SQL SERVER) la fecha y hora del sitema, nose si mi codigo es el problema o la forma que lo hago ya investigue un monton pero no logro resolverlo espero que me den una manito
(En el Load hago lo siguiente)
Espero que todos me den una mano ya que la necesito para seguir avanzando
(En el Load hago lo siguiente
1
2
3
4
5
6
7
8
9
10
11
Dim Busqueda As String
Busqueda = "Select Max(Id_fichamercaderia) From ficha_mercaderia"
Dim SC As New SqlCommand(Busqueda, objConn)
Dim Id As Integer
Dim Idtotal As Integer
objConn.Open()
Id = SC.ExecuteScalar
objConn.Close()
Idtotal = Id + 1
txt_cod.Text = Idtotal
txt_fecha_hora.Text = Now
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
Public Sub btn_guardar_Click(sender As Object, e As EventArgs) Handles btn_guardar.Click
objConn.Open()
objCmd.CommandType = CommandType.Text
If txt_clasificacion.Text = "" Or txt_descripcion.Text = "" Then
MsgBox("LLENE TODOS LOS CAMPOS", 0 + 16, "ERROR DE CARGA DE DATOS")
Exit Sub
End If
objCmd.CommandType = CommandType.Text
objCmd.CommandText = "INSERT INTO ficha_mercaderia (id_fichamercaderia,descripcion,unid_medida,impuesto,clasificacion,fecha_hora)
VALUES ('" & txt_cod.Text & "','" & txt_descripcion.Text & "','" & cmb_medida.SelectedItem & "','" & cmb_impuesto.Text & "','" & txt_clasificacion.Text & "','" & txt_fecha_hora.text & "')"
objCmd.Connection = objConn
Try
b = objCmd.ExecuteNonQuery()
If b > 0 Then
MessageBox.Show("DATOS GUARDADOS ")
End If
Catch q As Exception
MessageBox.Show(q.Message, "Error")
Finally
End Try
limpiar()
Try
Catch b As Exception
MessageBox.Show(b.Message, "Error")
End Try
Dim Busqueda As String
Busqueda = "Select Max(Id_fichamercaderia) From ficha_mercaderia"
Dim SC As New SqlCommand(Busqueda, objConn)
Dim Id As Integer
Dim Idtotal As Integer
Id = SC.ExecuteScalar
Idtotal = Id + 1
txt_cod.Text = Idtotal
txt_fecha_hora.Text = Now
objConn.Close()
Exit Sub
End Sub
Espero que todos me den una mano ya que la necesito para seguir avanzando
Valora esta pregunta


0