using command button instead of datacontrol

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jul 2007
Posts: 97
Reputation: mayank_ati is an unknown quantity at this point 
Solved Threads: 0
mayank_ati's Avatar
mayank_ati mayank_ati is offline Offline
Junior Poster in Training

using command button instead of datacontrol

 
0
  #1
Jul 13th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: using command button instead of datacontrol

 
0
  #2
Jul 13th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 97
Reputation: mayank_ati is an unknown quantity at this point 
Solved Threads: 0
mayank_ati's Avatar
mayank_ati mayank_ati is offline Offline
Junior Poster in Training

Re: using command button instead of datacontrol

 
0
  #3
Jul 13th, 2007
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...
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: using command button instead of datacontrol

 
0
  #4
Jul 13th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 97
Reputation: mayank_ati is an unknown quantity at this point 
Solved Threads: 0
mayank_ati's Avatar
mayank_ati mayank_ati is offline Offline
Junior Poster in Training

Re: using command button instead of datacontrol

 
0
  #5
Jul 13th, 2007
thanks !!!!
it worked.....
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,134
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 132
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: using command button instead of datacontrol

 
0
  #6
Jul 17th, 2007
what bout try yourself before ask for help and if possibel posting your code instead of asking for complete solution.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 97
Reputation: mayank_ati is an unknown quantity at this point 
Solved Threads: 0
mayank_ati's Avatar
mayank_ati mayank_ati is offline Offline
Junior Poster in Training

Re: using command button instead of datacontrol

 
0
  #7
Jul 17th, 2007
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!
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 43
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: using command button instead of datacontrol

 
0
  #8
Jul 17th, 2007
Originally Posted by mayank_ati View 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.
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 97
Reputation: mayank_ati is an unknown quantity at this point 
Solved Threads: 0
mayank_ati's Avatar
mayank_ati mayank_ati is offline Offline
Junior Poster in Training

Re: using command button instead of datacontrol

 
0
  #9
Jul 18th, 2007
thanx for your opinion....
but i guess data control has some limitations...
i may be wrong though.....
kindly guide me.....
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 43
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: using command button instead of datacontrol

 
0
  #10
Jul 18th, 2007
Originally Posted by mayank_ati View Post
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC