Buenas... tengo un formulario el cual contiene textbox checkbox list y upload de archivos...
hasta el momento he visto hasta lo q es el checkboxlist y el textbox lo he logrado almacenar en la base de datos sin ningun problema, pero el CBL no puedo lograrlo y he intentado de muchas maneras...
espero puedan ayudarme...porque al eliminar todo lo q es checkbox puedo almacenar los datos, pero asi no me guarda nada....
dejo una imagen del formulario
http://i154.photobucket.com/albums/s272/alcobe/formulario_zps9d89f81b.jpg
Cita: Imports System.Data
Imports System.Data.SqlClient
Partial Class Ingresar
Inherits System.Web.UI.Page
Dim coneccion As SqlConnection
'crear cadena de conexion
Dim cs As String = "Data Source=.\SQLEXPRESS;AttachDbFilename='|DataDirecto ry|\DB.mdf';Integrated Security=True;User Instance=True"
Dim con As New SqlConnection(cs)
Protected Sub btnIng_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnIng.Click
Try
'abrir conexión
con.Open()
'declarar variables
Dim Cod As String
Dim Nom As String
Dim Cant As String
Dim Det As String
Dim Serial As String
Dim Prec As String
Dim So As String
Dim Lic As String
Dim LicOff As String
Dim Licav As String
Dim LicOtros As String
Dim Obs As String
Dim FFact As String
Dim NFact As String
Dim Prov As String
Dim Cont As String
Dim Ncont As String
Dim User As String
Dim Depto As String
Dim sql As String
'Dim foto As Byte
'asignar los textbox a las variables correspondientes
Cod = TextBoxCod.Text
Nom = TextBoxNombre.Text
Cant = TextBoxCant.Text
Det = TextBoxDet.Text
Serial = TextBoxSer.Text
Prec = TextBoxPre.Text
So = TextBoxSO.Text
Lic = CBLLic.SelectedItem.Text
LicOff = CBLOffice.SelectedItem.Text
Licav = CBLav.SelectedItem.Text
LicOtros = CBOtros.Text
Obs = TextBoxObs.Text
FFact = TextBoxFFact.Text
NFact = TextBoxNFact.Text
Prov = TextBoxProv.Text
Cont = TextBoxNomCon.Text
Ncont = TextBoxNumCon.Text
User = TextBoxUsuario.Text
Depto = DDLDepto.SelectedItem.Text
'foto = upfoto.FileName
'LicSOSi = SOSI.Checked
'licsono = SONO.Checked
'sentencia SQL
sql = "INSERT INTO TablaDB VALUES ('" & Cod & "','" & Nom & "','" & Cant & "','" & Det & "','" & Serial & "','" & Prec & "','" & So & "','" & Lic & "','" & LicOff & "','" & Licav & "','" & LicOtros & "','" & Obs & "','" & FFact & "','" & NFact & "','" & Prov & "','" & Cont & "','" & Ncont & "','" & User & "','" & Depto & "') "
'creo objeto command
Dim command As New SqlCommand(sql, con)
'ejecuto sentencia sql
command.ExecuteNonQuery()
Catch ex As Exception
'mostrar mensaje de error
' lblError.Visible = True
'MsgBox("Error, Algo te falta!...", MsgBoxStyle.Critical, "Ojoooooo")
Finally
'lblIngresar.Visible = True
con.Close()
'Limpiar cajas de texto
TextBoxNombre.Text = ""
TextBoxCod.Text = ""
TextBoxUsuario.Text = ""
TextBoxCant.Text = ""
TextBoxDet.Text = ""
TextBoxSer.Text = ""
TextBoxPre.Text = ""
TextBoxSO.Text = ""
'TextBoxLic.Text = ""
TextBoxObs.Text = ""
TextBoxFFact.Text = ""
TextBoxNFact.Text = ""
TextBoxProv.Text = ""
TextBoxNomCon.Text = ""
TextBoxNumCon.Text = ""
' CBLLic.SelectedValue = False
' CBLOffice.SelectedValue = False
' CBLav.SelectedValue = False
CBOtros.Checked = False
End Try
End Sub
Protected Sub btnLimpiar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLimpiar.Click
'Limpiar cajas de texto
TextBoxNombre.Text = ""
TextBoxCod.Text = ""
TextBoxUsuario.Text = ""
TextBoxCant.Text = ""
TextBoxDet.Text = ""
TextBoxSer.Text = ""
TextBoxPre.Text = ""
TextBoxSO.Text = ""
'TextBoxLic.Text = ""
TextBoxObs.Text = ""
TextBoxFFact.Text = ""
TextBoxNFact.Text = ""
TextBoxProv.Text = ""
TextBoxNomCon.Text = ""
TextBoxNumCon.Text = ""
'CBLLic.SelectedValue = False
' CBLOffice.SelectedValue = False
'CBLav.SelectedValue = False
CBOtros.Checked = False
End Sub
Protected Sub CBLLic_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CBLLic.SelectedIndexChanged
End Sub
Protected Sub CBLOffice_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CBLOffice.SelectedIndexChanged
' If CBLOffice.SelectedValue = True Then
CBLOffice.Text = CBLOffice.SelectedValue
' End If
End Sub
Protected Sub CBLav_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CBLav.SelectedIndexChanged
' If CBLav.SelectedValue = True Then
CBLav.Text = CBLav.SelectedValue
' End If
End Sub
Protected Sub CBOtros_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CBOtros.CheckedChanged
If CBOtros.Checked = True Then
CBOtros.Text = "Licencia de Otros productos presente"
ElseIf CBOtros.Checked = False Then
CBOtros.Text = "No Hay Licencia de otros productos"
End If
End Sub
End Class