Ver Mensaje Individual
  #3 (permalink)  
Antiguo 05/07/2012, 17:08
thetemptation7
 
Fecha de Ingreso: junio-2012
Mensajes: 12
Antigüedad: 11 años, 10 meses
Puntos: 0
Respuesta: carrito d compras asp.net

hola

aquí está el método con el q trato d insertar a la bd

Cita:
Protected Sub save()
Dim oCnn As New MySqlConnection
'Dim i As Integer = CInt(Membership.GetUser().ProviderUserKey)

oCnn.ConnectionString = System.Configuration.ConfigurationManager.Connecti onStrings("minegocioConnectionString").ConnectionS tring
oCnn.Open()

Try

Dim comando As MySqlCommand = New MySqlCommand
comando.CommandText = "select max(NotaId) from tbl_notas"
comando.Connection = oCnn

Dim inc As Integer
inc = comando.ExecuteScalar() + 1

Dim strSql As String = "insert into tbl_notas(NotaId,ClienteId,FechaHora) values ('" & inc & "', '" _
& DropDownList1.SelectedValue.ToString & "',now())"

Dim Comand As MySqlCommand = New MySqlCommand(strSql, oCnn)
Comand.ExecuteNonQuery()

Dim cor As Integer
Dim cmd2 As New MySqlCommand("select max(NotaId) from tbl_notas", oCnn)
cor = cmd2.ExecuteScalar()


Dim Consulta As String = "insert into tbl_detallenotas (NotaId,ProductoId,Producto,Precio,Cantidad,Total) values(" & _
" @NotaId, @ProductoId,@Producto,@Precio,@Cantidad,@Total)"

Dim Comando2 As MySqlCommand = New MySqlCommand(Consulta, oCnn)

For Each row As GridViewRow In GridView1.Rows

Comando2.Parameters.Clear()

Comando2.Parameters.AddWithValue("@NotaId", cor)
Comando2.Parameters.AddWithValue("@ProductoId", row.Cells(1).Text)
Comando2.Parameters.AddWithValue("@Producto", row.Cells(2).Text)
Comando2.Parameters.AddWithValue("@Precio", CDec(row.Cells(3).Text))
Comando2.Parameters.AddWithValue("@Cantidad", CInt(row.Cells(4).Text))
Comando2.Parameters.AddWithValue("@Total", CDec(row.Cells(5).Text))

Comando2.ExecuteNonQuery()
Next

MsgBox("Su venta ha sido aceptada con el número de pedido : " & cor, vbInformation, "Confirmación")
Catch ex As Exception
MsgBox(ex.Message)
Finally
oCnn.Close()
End Try
End Sub
con esto ahora me marca error, primero me decía q el valor d la cadena d entrada no es válida y después cuando trato d convertir a entero el campo Cantidad

gracias x responder