Results 1 to 5 of 5

Thread: Writing to Access DB

  1. #1

    Thread Starter
    Hyperactive Member Jonny1409's Avatar
    Join Date
    Mar 2005
    Posts
    308

    Writing to Access DB

    I'm trying to write some fields into a table in an Access DB and am having a problem.

    My code is as follows:
    Code:
    Dim cn As adodb.Connection
    Dim rs As adodb.Recordset
    Dim cString As String
    cString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=ABC.mdb;Persist Security Info=False;"
     
    Set cn = New adodb.Connection
    cn.Open cString
    Set rs = New adodb.Recordset
    
    With rs
        .Open "tbl_ABC", cn, adOpenKeyset, adLockOptimistic
        .AddNew
        .Fields("Field1").Value = "Test"
        .Fields("Field2").Value = Now()
        .Fields("Field3").Value = "abcdefghijklm.xls"
        .Update
        .Close
    End With
    For some reason it is failing on the "Field3" line with an error number -2147418105.

    Can anyone help identify what I'm doing wrong ?

    Thanks,

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Writing to Access DB

    1) What is the type of the field?
    2) What is the max size of that field?
    3) Also check if you have spelled the field correctly
    Last edited by Siddharth Rout; Feb 19th, 2010 at 06:44 AM.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Writing to Access DB

    Also, what is the verbage of the error message? What is it telling you?

  4. #4
    Hyperactive Member Condomx's Avatar
    Join Date
    Dec 2009
    Location
    Iligan City,Philippines
    Posts
    327

    Re: Writing to Access DB

    it is because you are calling a field that have "." sequence and that is in under "" which read as a statement..
    ~[L!f3 !s @ll @ab0ut l3@rn!ng]~

    ~*D0nt Give up, h0pe is always present*~

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Writing to Access DB

    Thread moved to 'Database Development' forum (the 'VB6' forum is only meant for questions which don't fit in more specific forums)
    Quote Originally Posted by Condomx View Post
    it is because you are calling a field that have "." sequence and that is in under "" which read as a statement..
    I don't know what you meant by that, but after comparing it to the code in post #1, I'm as sure as I can be that you are not correct.

Posting Permissions

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



Click Here to Expand Forum to Full Width