943,552 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Jul 13th, 2007
0

using command button instead of datacontrol

Expand Post »
hey i am new to visual basic programming...just 15-20 days into it...
i wanna know how can i use command button to access the ms access files instead of using the data control....how can i do that????
i have tried a lot of things but to no effect .... please help me with this!!!!
i tried to find this solution in the solved threads but without any success.
Similar Threads
Reputation Points: 38
Solved Threads: 0
Junior Poster in Training
mayank_ati is offline Offline
97 posts
since Jul 2007
Jul 13th, 2007
0

Re: using command button instead of datacontrol

Hi,

Add "Microsoft ActiveX objects 2.0" References to the project.
use this code:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim rs As New ADODB.Recordset
  2. Dim AC As New ADODB.Connection
  3. With AC
  4. .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDB.mdb;Persist Security Info=False"
  5. .Open
  6. End With
  7. ssql = "Select * from MyTable"
  8. Set rs=Nothing
  9. RS.Open ssql,AC
  10. If RS.EOF Then
  11. ' No Record Found
  12. Else
  13. 'Records Found
  14. End If

Regards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Jul 13th, 2007
0

Re: using command button instead of datacontrol

hey....
thanks for the code but on command click its not showing the records in the textboxes...
do i have to do anything...for that...likeways changing the properties..
thanks...
Reputation Points: 38
Solved Threads: 0
Junior Poster in Training
mayank_ati is offline Offline
97 posts
since Jul 2007
Jul 13th, 2007
0

Re: using command button instead of datacontrol

Hi,

In continuation with above code:

If RS.EOF Then
' No Record Found
Else
text1.text = RS(0)
text2.text = RS(1)
text3.text = RS(2)
text4.text = RS(3)
text5.text = RS(4)
End If


Regards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Jul 13th, 2007
0

Re: using command button instead of datacontrol

thanks !!!!
it worked.....
Reputation Points: 38
Solved Threads: 0
Junior Poster in Training
mayank_ati is offline Offline
97 posts
since Jul 2007
Jul 17th, 2007
0

Re: using command button instead of datacontrol

what bout try yourself before ask for help and if possibel posting your code instead of asking for complete solution.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Jul 17th, 2007
0

Re: using command button instead of datacontrol

i tried it my self quite a lot....
but just couldnt get the solution....
i know the rules .... sure dude....dont get angry...
i checked all the threads....but jus couldt get over..it....
i actully am a new programmer and dont kno much..
i just got as far as using a data control.....got it!
Reputation Points: 38
Solved Threads: 0
Junior Poster in Training
mayank_ati is offline Offline
97 posts
since Jul 2007
Jul 17th, 2007
0

Re: using command button instead of datacontrol

Click to Expand / Collapse  Quote originally posted by mayank_ati ...
hey i am new to visual basic programming...just 15-20 days into it...
i wanna know how can i use command button to access the ms access files instead of using the data control....how can i do that????
i have tried a lot of things but to no effect .... please help me with this!!!!
i tried to find this solution in the solved threads but without any success.
Why do you want to use the command button instead of a data control? Coz if you'll do that and then if you have another command you'll have to call/access again the database. the advantage of the data control is that you only ask the data control to display the data you wanted without "connecting again" to the database... just an opinion/thought hehehe, please don't get me wrong
Last edited by jireh; Jul 17th, 2007 at 9:48 pm.
Reputation Points: 11
Solved Threads: 49
Posting Whiz
jireh is offline Offline
316 posts
since Jul 2007
Jul 18th, 2007
0

Re: using command button instead of datacontrol

thanx for your opinion....
but i guess data control has some limitations...
i may be wrong though.....
kindly guide me.....
Reputation Points: 38
Solved Threads: 0
Junior Poster in Training
mayank_ati is offline Offline
97 posts
since Jul 2007
Jul 18th, 2007
0

Re: using command button instead of datacontrol

Click to Expand / Collapse  Quote originally posted by mayank_ati ...
thanx for your opinion....
but i guess data control has some limitations...
i may be wrong though.....
kindly guide me.....
yeah! you cannot put them in modules hehehe I use controls than declaring variables to lessen the code so that it more readable. but of course I use variables too but only when needed. So how's your project now?
By the way are you using
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Option Explicit
in your vb?
Last edited by jireh; Jul 18th, 2007 at 4:15 am.
Reputation Points: 11
Solved Threads: 49
Posting Whiz
jireh is offline Offline
316 posts
since Jul 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: combining vb6 and flash mx
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: changing the database's path....





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC