Results 1 to 19 of 19

Thread: Problems adding data to access

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Problems adding data to access

    Hi,
    I have problems with adding data to pass access

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim username As String
    3.     Dim password As String
    4.     Dim title As String
    5.    
    6.     Set AConn = New ADODB.Connection
    7.     Set ARecd = New ADODB.Recordset
    8.     Set aComm = New ADODB.Command
    9.    
    10.     title = title_t.Text
    11.     password = pass_t.Text
    12.     username = username_t.Text
    13.     CString = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=pass.mdb; DefaultDir=" & App.Path & ";"
    14.     AConn.ConnectionString = CString
    15.     AConn.Open
    16.    
    17.     RString = "insert into pass (`סיסמא`,`שם משתמש`,`נושא`,) values(" & password & "," & username & "," & title & ")"
    18.     ARecd.Open RString
    19. End Sub

    i dont know what is the broblem
    i cannot give the error becuase its hebrew..

    What can be the problem ?

    -k3pos

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

    Re: Problems adding data to access

    First off, you shouldn't be using a recordset to run an action statement (Insert/Update/Delete/...), as it wastes memory and slows things down. You should use the .Execute method of the connection, or use a command object, eg:
    VB Code:
    1. AConn.Execute RString

    Next up, you need to close all of your objects (AConn, ARecd, aComm) when you have finished with them, otherwise you are wasting memory and risking database corruption.

    As to the problem.. without knowing roughly what the error message was we can only guess what it was, but one obvious issue is an extra comma: `,) values("

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Problems adding data to access

    It says ther will be a problem in the SQL command.
    i mean the insert script..

    what is the problem ther ???

    error : Not enough patameters : Needed Only 1 Parameter

    but ther is allready 3 parameters without the ID parameter
    -k3pos
    Last edited by k3pos; Feb 25th, 2007 at 11:08 AM.

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

    Re: Problems adding data to access

    My first two points aren't about stopping the error - they are about getting it working properly and safely.

    You currently have an extra comma before the bracket - which shows that you want to put an extra field in (which you don't). Remove the comma that is just before the close bracket, at it should be fine. eg:
    VB Code:
    1. RString = "insert into pass (`סיסמא`,`שם משתמש`,`נושא[u]`)[/u] values(" & password & "," & username & "," & title & ")"
    2.     AConn.Execute RString

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Problems adding data to access

    IT WORKS NOW!!

    thanks for the help

    -k3pos
    Last edited by k3pos; Feb 25th, 2007 at 11:19 AM.

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

    Re: Problems adding data to access

    Ah.. I just realised that your fields are probably all text, for that you need to wrap the values in single quotes:
    values('" & password & "','" & username & "','" & title & "')"

  7. #7
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Problems adding data to access

    Your trying to insert string data into the database (at least that is my guess here), all string data going to the DB needs to be surrounded by single qoutes.

    VB Code:
    1. "insert into pass (`סיסמא`,`שם משתמש`,`נושא`) values('" & password & "','" & username & "','" & title & "')"
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Problems adding data to access

    Ok Thanks.

    -k3pos

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Problems adding data to access

    Sorry For The Second Post.

    I need help,
    it added and its ok thank you
    but now i need that the datagird will be refreshed
    when i add new data i need to get out and get in again for to see the new data in the dagagird

    what do i do?

    -k3pos

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

    Re: Problems adding data to access

    You need to re-fill the DataGrid. How you do that depends on how you are currently filling it in the first place.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Problems adding data to access

    How can i refill it ?
    any guide for that?
    i see in your sign that you have for flixgrid
    i need for datagrid

    -k3pos

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

    Re: Problems adding data to access

    Quote Originally Posted by k3pos
    How can i refill it ?
    What is the answer to this question?
    Quote Originally Posted by si_the_geek
    You need to re-fill the DataGrid. How you do that depends on how you are currently filling it in the first place.

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Problems adding data to access

    i fill it regulary with the DATASOURCE...

  14. #14
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    830

    Re: Problems adding data to access

    give me all the name of Column in your table, and i will help from there. next time provide the whole info

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Problems adding data to access

    please do exmaple with 'as' 'sd' dw'
    and i will edit

  16. #16
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    830

    Re: Problems adding data to access

    "insert into pass (`סיסמא`,`שם משתמש`,`נושא`) values('" & password & "','" & username & "','" & title & "')"

    i need you to provide the whole info name of columns in your table, so we can help you

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: Problems adding data to access

    but its about 10 - 12 in hebrew.. can you see hebrew?

  18. #18
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    830

    Re: Problems adding data to access

    no i cant read hebrew

  19. #19
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    830

    Re: Problems adding data to access

    refresh the recordset

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