| View previous topic :: View next topic |
| Author |
Message |
Mitesh2004 Freshman
Joined: 26 Jan 2004 Posts: 43
|
Posted: Feb 10th, 2004 01:47 PM Post subject: Move pointer to specified record |
|
|
Hello,
I am using ADO to connect to my database. How would i get the database to point to the record that is specified by the user by selecting from a DataList.
Please let me know if you dont understand what i mean and i will try to clarify. |
|
| Back to top |
|
Andir Centurion

Joined: 21 Dec 2003 Posts: 184 Location: Chicago Area
|
Posted: Feb 11th, 2004 01:13 AM Post subject: |
|
|
hmm...this wouldn't happen to still deal with the deleteion of records would it? If so, try using the ADO database Execute method. You can use your Database connection object to delete the specific record. DB.Execute "DELETE * FROM Tablename WHERE someID = " & Something & ";"
If it's not the same issue, I thought simply selecting the record in a dataset moved the pointer. It may be how you set the Cursor Type. You can specify this, but I can't remember right now and I'm not anywhere I can pull that up. :\ _________________ If you happen to see little people sitting on your desk...don't tell anyone or they might think your crazy too. |
|
| Back to top |
|
Mitesh2004 Freshman
Joined: 26 Jan 2004 Posts: 43
|
Posted: Feb 11th, 2004 05:37 AM Post subject: |
|
|
Hi Andir,
Yes, i am still trying to deal with deleting the record. Here is the code that i have written for it, but it is still not working:
Dim adoConn As New ADODB.Connection
Dim adoCmd As New ADODB.Command
Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\My Documents\Mitesh\Uni Stuff\Final Year Project\Implementation\planner.mdb;Persist Security Info=False"
adoConn.ConnectionString = strConn
adoConn.Open
adoConn.Execute ("DELETE * FROM Event WHERE EventName = " & dlstEvents.Text)
It comes up with a Runtime Error "Syntax Error (Missing operator) in query expression"
Please please please could you help me.... cheers!! |
|
| Back to top |
|
Andir Centurion

Joined: 21 Dec 2003 Posts: 184 Location: Chicago Area
|
Posted: Feb 11th, 2004 06:45 AM Post subject: |
|
|
Hmm...are you keeping the Recordset and database open or is this only the button_click event?
The error your getting might be because of SQL syntax. You should have a single quote before and after every string in the SQL statement:
adoConn.Execute "DELETE * FROM Event WHERE EventName = '" & dlstEvents.Text & "';"
(oh, and get rid of your Parenthesis. You only need them if your setting something equal to the result of the function.) _________________ If you happen to see little people sitting on your desk...don't tell anyone or they might think your crazy too. |
|
| Back to top |
|
Mitesh2004 Freshman
Joined: 26 Jan 2004 Posts: 43
|
Posted: Feb 11th, 2004 08:48 AM Post subject: |
|
|
Thanks andir... this seems to have worked. But how do i get that record to disappear from the contents of the List once the 'Delete' button is clicked on?
At the moment, the record still stays on the List Box (Although it does delete from the database). |
|
| Back to top |
|
Andir Centurion

Joined: 21 Dec 2003 Posts: 184 Location: Chicago Area
|
Posted: Feb 12th, 2004 01:02 AM Post subject: |
|
|
you have to requery the database...try doing:
Datalist1.requery
or
RS.requery
then rebind your datalist. (set Datalist1.recordsource = RS) _________________ If you happen to see little people sitting on your desk...don't tell anyone or they might think your crazy too. |
|
| Back to top |
|
|