|
-
Feb 25th, 2007, 10:22 AM
#1
Thread Starter
Addicted Member
Problems adding data to access
Hi,
I have problems with adding data to pass access
VB Code:
Private Sub Command1_Click()
Dim username As String
Dim password As String
Dim title As String
Set AConn = New ADODB.Connection
Set ARecd = New ADODB.Recordset
Set aComm = New ADODB.Command
title = title_t.Text
password = pass_t.Text
username = username_t.Text
CString = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=pass.mdb; DefaultDir=" & App.Path & ";"
AConn.ConnectionString = CString
AConn.Open
RString = "insert into pass (`סיסמא`,`שם משתמש`,`נושא`,) values(" & password & "," & username & "," & title & ")"
ARecd.Open RString
End Sub
i dont know what is the broblem
i cannot give the error becuase its hebrew..
What can be the problem ?
-k3pos
-
Feb 25th, 2007, 10:46 AM
#2
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:
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("
-
Feb 25th, 2007, 11:03 AM
#3
Thread Starter
Addicted Member
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.
-
Feb 25th, 2007, 11:09 AM
#4
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:
RString = "insert into pass (`סיסמא`,`שם משתמש`,`נושא[u]`)[/u] values(" & password & "," & username & "," & title & ")"
AConn.Execute RString
-
Feb 25th, 2007, 11:14 AM
#5
Thread Starter
Addicted Member
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.
-
Feb 25th, 2007, 11:19 AM
#6
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 & "')"
-
Feb 25th, 2007, 11:21 AM
#7
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:
"insert into pass (`סיסמא`,`שם משתמש`,`נושא`) values('" & password & "','" & username & "','" & title & "')"
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Feb 25th, 2007, 11:24 AM
#8
Thread Starter
Addicted Member
Re: Problems adding data to access
-
Feb 25th, 2007, 11:41 AM
#9
Thread Starter
Addicted Member
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
-
Feb 25th, 2007, 12:01 PM
#10
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.
-
Feb 26th, 2007, 11:08 AM
#11
Thread Starter
Addicted Member
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
-
Feb 26th, 2007, 11:10 AM
#12
Re: Problems adding data to access
 Originally Posted by k3pos
How can i refill it ?
What is the answer to this question?
 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.
-
Feb 27th, 2007, 07:46 AM
#13
Thread Starter
Addicted Member
Re: Problems adding data to access
i fill it regulary with the DATASOURCE...
-
Mar 1st, 2007, 02:47 AM
#14
Fanatic Member
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
-
Mar 1st, 2007, 11:45 AM
#15
Thread Starter
Addicted Member
Re: Problems adding data to access
please do exmaple with 'as' 'sd' dw'
and i will edit
-
Mar 2nd, 2007, 01:36 AM
#16
Fanatic Member
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
-
Mar 3rd, 2007, 07:48 AM
#17
Thread Starter
Addicted Member
Re: Problems adding data to access
but its about 10 - 12 in hebrew.. can you see hebrew?
-
Mar 5th, 2007, 01:59 AM
#18
Fanatic Member
Re: Problems adding data to access
-
Mar 5th, 2007, 02:01 AM
#19
Fanatic Member
Re: Problems adding data to access
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|