• Viernes 29 de Marzo de 2024, 15:38

Autor Tema:  Vb Net + Access 2007  (Leído 2304 veces)

Seguis

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
Vb Net + Access 2007
« en: Domingo 15 de Junio de 2014, 18:00 »
0
Saludos a todos, trato de agregar datos a Access 2007 con Vb net 2005, pero me sale el siguiente error:

No se controló System.Runtime.InteropServices.COMException
  ErrorCode=-2147217900
  Message="Error de sintaxis en la cadena en la expresión de consulta ''3107)'." //Este "3107" se trata del numero que ingreso en textbox2.text
  Source="Microsoft Office Access Database Engine"
  StackTrace:
       en ADODB.ConnectionClass.Execute(String CommandText, Object& RecordsAffected, Int32 Options)
       en Agenda.Form1.Button1_Click(Object sender, EventArgs e) en C:\Users\Seguix\AppData\Local\Temporary Projects\Agenda\Form1.vb:línea 10
       en System.Windows.Forms.Control.OnClick(EventArgs e)
       en System.Windows.Forms.Button.OnClick(EventArgs e)
       en System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       en System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       en System.Windows.Forms.Control.WndProc(Message& m)
       en System.Windows.Forms.ButtonBase.WndProc(Message& m)
       en System.Windows.Forms.Button.WndProc(Message& m)
       en System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       en System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       en System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       en System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       en System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       en System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       en System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       en System.Windows.Forms.Application.Run(ApplicationContext context)
       en Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       en Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       en Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       en Agenda.My.MyApplication.Main(String[] Args) en 17d14f5c-a337-4978-8281-53493378c1071.vb:línea 81
       en System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       en System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       en Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       en System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       en System.Threading.ThreadHelper.ThreadStart()

El codigo es:

Public Class Form1

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

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Abrir.Open()
        SQL = "INSERT INTO Prueba(Nombre,Numero) VALUES(" & TextBox1.Text & ",'" & Val(TextBox2.Text) & ")"
        RS = Abrir.Execute(SQL)
        Abrir.Close()
    End Sub
End Class

El codigo del modulo es:

Module Module1
    Public SQL As String
    Public RS As New ADODB.Recordset 'Espacios de memoria

    Public Abrir As ADODB.Connection 'Variable para conexion

    Public Sub CONECTAR()
        Abrir = New ADODB.Connection
        Abrir.ConnectionString = "PROVIDER=MICROSOFT.ACE.OLEDB.12.0;DATA SOURCE= C:\Users\Seguix\Documents\Base.accdb"
    End Sub
End Module