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
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("
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
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
Re: Problems adding data to access
IT WORKS NOW!!
thanks for the help
-k3pos
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 & "')"
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 & "')"
Re: Problems adding data to access
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
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.
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
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.
Re: Problems adding data to access
i fill it regulary with the DATASOURCE...
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
Re: Problems adding data to access
please do exmaple with 'as' 'sd' dw'
and i will edit
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
Re: Problems adding data to access
but its about 10 - 12 in hebrew.. can you see hebrew?
Re: Problems adding data to access
Re: Problems adding data to access