ADODB Insert into SQL Server-VBForums
Results 1 to 6 of 6

Thread: ADODB Insert into SQL Server

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    3

    ADODB Insert into SQL Server

    Hello All, this is my first post here!

    I would like some help with an insert i'm trying to perform on my DB.

    My connection is defined in a module so i can use the connection everywhere in the project like this:

    Code:
    public Const oConn As String = "Provider=sqloledb;" & _
        "Data source=SERVER;" & _
        "Initial Catalog=NORTHWND;" & _
        "Trusted_Connection=yes;"

    The error i get when i try to do the insert is the following: Qualifier not valid:

    The line of code giving the error is this:


    Code:
           strSql = "Insert into Categories (CategoryName, Description, Picture)" & _
                    "Values ('" & txtCategoria.Text & "', '" & txtDescripcion.Text & "', '0x151C2F00020000000D000E' )"
            
            Set cmd = New ADODB.Command
    
            ' oConn is marked when the error happens
            oConn.Execute strSql
            
            cmd.Execute ostrSql
    What would i be missing?

    Thanks in advance!

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,202

    Re: ADODB Insert into SQL Server

    Is picture a text field?

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    16,877

    Re: ADODB Insert into SQL Server

    Your connection must be an object, not a string. The FAQ link in the DB portion of the forums has good examples for VB and ADO.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,202

    Re: ADODB Insert into SQL Server

    Yep, I missed that. The definition is for a connection string, not a connection

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    3

    Re: ADODB Insert into SQL Server

    Quote Originally Posted by LaVolpe View Post
    Your connection must be an object, not a string. The FAQ link in the DB portion of the forums has good examples for VB and ADO.
    Hey LaVolpe

    My issue is that i'm trying to access the connection from the module so i dont have to define one on every form.

    i'm kinda new here, can you please provideme that FAQ link so i can search it?

    @DataMiser yeah its a picture!

    I'm just getting familiar with ADODB using Northwind DB sample.

    Thanks for your responses!

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    16,877

    Re: ADODB Insert into SQL Server

    Quote Originally Posted by dionismatos View Post
    Hey LaVolpe

    My issue is that i'm trying to access the connection from the module so i dont have to define one on every form.

    i'm kinda new here, can you please provideme that FAQ link so i can search it?
    http://www.vbforums.com/showthread.p...ay-13-2011#ado
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.