Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/05/2010, 00:29
Avatar de Fergusbra
Fergusbra
 
Fecha de Ingreso: mayo-2010
Ubicación: San Andrés Cholula, Puebla, Mexico, Mexico
Mensajes: 6
Antigüedad: 14 años, 5 meses
Puntos: 0
Ayda con error en conexion.execute(sql)

Hola.
Estoy desarrollando un programa para facilitar algunas de mis actividades en la oficina por lo que es un programa sin fines de lucro y totalmente personal.
pero e tenido unos problemas y no encuentro mi error o mas bien no doy el como resolverlo...
es una base de datos de access 2007 conectada a visual basic 2008 express edition.

para conectar la base cree un modulo donde declaro lo siguiente:

Module Module1
Public conexion As ADODB.Connection
Public Sub conectar()
conexion = New ADODB.Connection
conexion.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\xxxxx\Documents\xxxxxx\xxxxxx.accd b"
conexion.Open()
End Sub

End Module

y después mando a llamar el modulo conectar en private sub form1:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conectar()
inabilitarcajas()
End Sub

el problema es al guardar, este es mi codigo:
Public Class Form1

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
End
End Sub
Public accion As String
Public sql As String
Private Sub inabilitarcajas()
Me.TextBox1.Enabled = False
Me.TextBox2.Enabled = False
Me.TextBox3.Enabled = False
Me.TextBox4.Enabled = False
Me.TextBox5.Enabled = False
Me.TextBox6.Enabled = False
Me.TextBox7.Enabled = False
Me.TextBox8.Enabled = False
Me.TextBox9.Enabled = False
Me.TextBox10.Enabled = False
Me.TextBox11.Enabled = False
End Sub
Private Sub habilitarcajas()
Me.TextBox1.Enabled = True
Me.TextBox2.Enabled = True
Me.TextBox3.Enabled = True
Me.TextBox4.Enabled = True
Me.TextBox5.Enabled = True
Me.TextBox6.Enabled = True
Me.TextBox7.Enabled = True
Me.TextBox8.Enabled = True
Me.TextBox9.Enabled = True
Me.TextBox10.Enabled = True
Me.TextBox11.Enabled = True
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conectar()
inabilitarcajas()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
habilitarcajas()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
accion = "nuevo"
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
habilitarcajas()
accion = "editar"
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim numero As String
Dim rs As ADODB.Recordset
numero = InputBox("digite el numero de plaza")
sql = "select * from Tabla1 wehere no_plaza='" & numero & "'"
rs = conexion.Execute(sql)

If rs.BOF <> True Then
rs.MoveFirst()
TextBox1.Text = rs.Fields(0).Value
TextBox2.Text = rs.Fields(1).Value
TextBox3.Text = rs.Fields(2).Value
TextBox4.Text = rs.Fields(3).Value
TextBox5.Text = rs.Fields(4).Value
TextBox6.Text = rs.Fields(5).Value
TextBox7.Text = rs.Fields(6).Value
TextBox8.Text = rs.Fields(7).Value
TextBox9.Text = rs.Fields(.Value
TextBox10.Text = rs.Fields(9).Value
TextBox11.Text = rs.Fields(10).Value
TextBox12.Text = rs.Fields(11).Value
Else
MsgBox("El registro no existe ")
End If
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim numero As String
Dim rs As ADODB.Recordset
numero = InputBox("digite el nombre del titular")
sql = "Select * from Tabla1 wehere titular='" & numero & "'"
rs = conexion.Execute(sql)

If rs.BOF <> True Then
rs.MoveFirst()
TextBox1.Text = rs.Fields(0).Value
TextBox2.Text = rs.Fields(1).Value
TextBox3.Text = rs.Fields(2).Value
TextBox4.Text = rs.Fields(3).Value
TextBox5.Text = rs.Fields(4).Value
TextBox6.Text = rs.Fields(5).Value
TextBox7.Text = rs.Fields(6).Value
TextBox8.Text = rs.Fields(7).Value
TextBox9.Text = rs.Fields(.Value
TextBox10.Text = rs.Fields(9).Value
TextBox11.Text = rs.Fields(10).Value
TextBox12.Text = rs.Fields(11).Value
Else
MsgBox("El registro no existe ")
End If
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim numero As String
Dim rs As ADODB.Recordset
numero = InputBox("digite la ficha del titular")
sql = "select * from Tabla1 wehere no_titular='" & numero & "'"
rs = conexion.Execute(sql)

If rs.BOF <> True Then
rs.MoveFirst()
TextBox1.Text = rs.Fields(0).Value
TextBox2.Text = rs.Fields(1).Value
TextBox3.Text = rs.Fields(2).Value
TextBox4.Text = rs.Fields(3).Value
TextBox5.Text = rs.Fields(4).Value
TextBox6.Text = rs.Fields(5).Value
TextBox7.Text = rs.Fields(6).Value
TextBox8.Text = rs.Fields(7).Value
TextBox9.Text = rs.Fields(.Value
TextBox10.Text = rs.Fields(9).Value
TextBox11.Text = rs.Fields(10).Value
TextBox12.Text = rs.Fields(11).Value
Else
MsgBox("El registro no existe ")
End If
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim numero As String
Dim rs As ADODB.Recordset
numero = InputBox("digite el nombre del candidato")
sql = "select * from Tabla1 wehere candidato='" & numero & "'"
rs = conexion.Execute(sql)

If rs.BOF <> True Then
rs.MoveFirst()
TextBox1.Text = rs.Fields(0).Value
TextBox2.Text = rs.Fields(1).Value
TextBox3.Text = rs.Fields(2).Value
TextBox4.Text = rs.Fields(3).Value
TextBox5.Text = rs.Fields(4).Value
TextBox6.Text = rs.Fields(5).Value
TextBox7.Text = rs.Fields(6).Value
TextBox8.Text = rs.Fields(7).Value
TextBox9.Text = rs.Fields(.Value
TextBox10.Text = rs.Fields(9).Value
TextBox11.Text = rs.Fields(10).Value
TextBox12.Text = rs.Fields(11).Value
Else
MsgBox("El registro no existe ")
End If
End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim numero As String
Dim rs As ADODB.Recordset
numero = InputBox("digite la ficha del candidato")
sql = "select * from Tabla1 wehere no_candidato='" & numero & "'"
rs = conexion.Execute(sql)

If rs.BOF <> True Then
rs.MoveFirst()
TextBox1.Text = rs.Fields(0).Value
TextBox2.Text = rs.Fields(1).Value
TextBox3.Text = rs.Fields(2).Value
TextBox4.Text = rs.Fields(3).Value
TextBox5.Text = rs.Fields(4).Value
TextBox6.Text = rs.Fields(5).Value
TextBox7.Text = rs.Fields(6).Value
TextBox8.Text = rs.Fields(7).Value
TextBox9.Text = rs.Fields(.Value
TextBox10.Text = rs.Fields(9).Value
TextBox11.Text = rs.Fields(10).Value
TextBox12.Text = rs.Fields(11).Value
Else
MsgBox("El registro no existe ")
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If accion = "nuevo" Then
sql = "insert into Tabla1 (no_plaza,titular,no_titular,candidato,no_candidat o,coordinacion,periodo,motivo,f_entrada,procede,f_ salida,ubicacion)" & "values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text & "','" & TextBox11.Text & "')"
conexion.Execute(sql)
MsgBox("El registro se guardo correctamente")
End If
If accion = "editar" Then
sql = "update Tabla1 set no_plaza='" & TextBox1.Text & "'" _
& "titular='" & TextBox2.Text & "'" _
& "no_titular='" & TextBox3.Text & "'" _
& "candidato='" & TextBox4.Text & "'" _
& "no_candidato='" & TextBox5.Text & "'" _
& "coordinacion='" & TextBox6.Text & "'" _
& "periodo='" & TextBox7.Text & "'" _
& "motivo='" & TextBox8.Text & "'" _
& "f_entrada='" & TextBox9.Text & "'" _
& "procede='" & TextBox10.Text & "'" _
& "f_salida='" & TextBox11.Text & "'" _
& "ubicacion='" & TextBox12.Text & "'"
Debug.Print(sql)

conexion.Execute(sql)
MsgBox("La edicion del registro se realizo con exito")
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim x As Integer
x = MsgBox("En realidad desea eliminar el registro?", MsgBoxStyle.YesNo)
If x = vbYes Then
sql = "delete from Tabla1 where no_plaza='" & TextBox1.Text & "'"
conexion.Execute(sql)
MsgBox("Registro eliminado")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""



End If

End Sub
End Class

El error que me sale es el siguiente y personalmente me tiene desesperado por favor alludenme!!

quería dejar una captura de pantalla pero no tengo la antigüedad suficiente
[URL=http://img18.imageshack.us/i/errorhp.jpg/][IMG]http://img18.imageshack.us/img18/1782/errorhp.th.jpg[/IMG][/URL]

Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]
el error lo marca en todas las secciones que utilizo conexion.Execute(sql) y dice: No se controló COMException
Error de sintaxis en la clausula FORM