Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting

Post new topic   Reply to topic
Move pointer to specified record
View previous topic :: View next topic  
Author Message
Mitesh2004
Freshman


Joined: 26 Jan 2004
Posts: 43

PostPosted: Feb 10th, 2004 01:47 PM    Post subject: Move pointer to specified record Reply with quote

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
View user's profile Send private message Send e-mail
Andir
Centurion


Joined: 21 Dec 2003
Posts: 184
Location: Chicago Area

PostPosted: Feb 11th, 2004 01:13 AM    Post subject: Reply with quote

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
View user's profile Send private message
Mitesh2004
Freshman


Joined: 26 Jan 2004
Posts: 43

PostPosted: Feb 11th, 2004 05:37 AM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Andir
Centurion


Joined: 21 Dec 2003
Posts: 184
Location: Chicago Area

PostPosted: Feb 11th, 2004 06:45 AM    Post subject: Reply with quote

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
View user's profile Send private message
Mitesh2004
Freshman


Joined: 26 Jan 2004
Posts: 43

PostPosted: Feb 11th, 2004 08:48 AM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Andir
Centurion


Joined: 21 Dec 2003
Posts: 184
Location: Chicago Area

PostPosted: Feb 12th, 2004 01:02 AM    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic