Windows XP with SP2 doesn't require anymore than one "\" in the root directory, and adding a second one doesn't hurt things. If you are using a different OS, then you might need to check for a trailing "\"
I still have code in one of my apps that fixes the pathname, but checked it out, and it doesn't matter for XP SP2.
I don't know if this is the best way but I fell in love with it:
Use UDL files - udls files are files that holds the connection string
so when you change the location of the DB you can enter this file without touching your code.
In your code you - call the udl file in the very place you used to call the DB file.
I used to work with access - I dont know if it can work with real DB's
I have a module for all DB related tasks. I can call this function from anywhere within the app, when I want to connect.
Code:
Function GetConnString() As String
GetConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Collection.mdb;Persist Security Info=False"
End Function
and here's another subroutine in the same module that calls it.
Code:
Sub DeleteFromClients()
strSQL = "DELETE * FROM CLIENT WHERE AccountNo="
strSQL = strSQL & frmClients.flx.TextMatrix(mrow, 0)
' Debug.Print strSQL
cn.Open GetConnString
cn.Execute strSQL
Set cn = Nothing
End Sub
This way, I only have to change one line of code if anything about the db changes. If I want to move to SQL, I change one thing (basically) for a new connection string.
Listen to me very carefully,to make it simple you have to do certain things.
1.If you are saving your exe in c:\application then save your mdb file in that very folder.
2.Now write the code as
conn.Open ("PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & App.Path & "\TEST.mdb"
App.path signifies the path of your exe i.e c:\application
I hope now its clear for you to grasp the basic.
well what rudraksh says is perfect but for that saumya s have to work out for that. at this place you should not expect exact program to be written by some other programmer for you.
once you get some work around pls try to find it out and make use of it.
In all previous posts what i found was none of the asking parties were intrested in doing some R&D, they were looking for spoon feeding. Pls avoid such things and try to find the solns once you get some work around. for example when it is told that you can get the things done using app.path then you should have studied about that function despite of posting another ques of how to use it.
I never meant to hurt any one but if at this time you will not make it a practice to find the things by your own this profession will be hard for you to survive. hope you will get the core and will not feel bad.
still we r all here to help each and every one in problem.
well what rudraksh says is perfect but for that saumya s have to work out for that. at this place you should not expect exact program to be written by some other programmer for you.
once you get some work around pls try to find it out and make use of it.
In all previous posts what i found was none of the asking parties were intrested in doing some R&D, they were looking for spoon feeding. Pls avoid such things and try to find the solns once you get some work around. for example when it is told that you can get the things done using app.path then you should have studied about that function despite of posting another ques of how to use it.
I never meant to hurt any one but if at this time you will not make it a practice to find the things by your own this profession will be hard for you to survive. hope you will get the core and will not feel bad.
still we r all here to help each and every one in problem.
Take Care!!
Hey Pranay, Come on man.he was just trying to find a solution in a socratic manner...
well what rudraksh says is perfect but for that saumya s have to work out for that. at this place you should not expect exact program to be written by some other programmer for you.
once you get some work around pls try to find it out and make use of it.
In all previous posts what i found was none of the asking parties were intrested in doing some R&D, they were looking for spoon feeding. Pls avoid such things and try to find the solns once you get some work around. for example when it is told that you can get the things done using app.path then you should have studied about that function despite of posting another ques of how to use it.
I never meant to hurt any one but if at this time you will not make it a practice to find the things by your own this profession will be hard for you to survive. hope you will get the core and will not feel bad.
still we r all here to help each and every one in problem.
Take Care!!
Dear pranay,
Thank u for ur comments or advice...
But one thing i want to tell u...No one can complete the whole project by using some Hints or some code ofcourse they have to do something by their own........
one thing i wanted to tell u is iam VB learner.............so some douts are common i think so...
After trying so manythings in so manyways..even then if i don't get then
i will seek help from forum...............
dear pranay,iam not expecting exact code from any programmer like u....
please see my first post of this topic...........actually i wanted to try in different way so i put a question..........again iam telling u i don't have any connection problem just i wanted to do in different way like as u said ......SPOON FEEDING
as u told about spoon feeding..........some may have some time restrictions due to that they may ask spoonfeeding.......................
pranay iam not accusing u.........just iam telling about myside.please don't feel bad......and understand others
ofcourse u are right............one have to do by himself or herself........then only they get knowledge.
hope i did't hurt u or anyone.............
actually my connection was working fine and just i wanted try it in another method like as in unix ie directory method.....
My heartful thanks for those who replying and answering my questions and responding to my queries.
REALLY MANY MANY THANKS FOR ALL OF U, WHO POSTED AND ANSWERED MY SILLY QUESTIONS IAM GREATFUL TO U ALL........I LEARNT MANY THINGS THANK U.THANK U.....VERY..VERY.MUCH
once again thank u
sowmya s
Last edited by sowmya s; March 16th, 2006 at 01:25 AM.
Some years ago I got my first job. I had to write a dll that translates sales or purchases into a transaction between the main program Oracle and a finance system.
Needless to say I knew nothing of oracle and Pl-SQL, of the finance system and I was not a too good VB programmer - and to make it better: three guys before me failed in accomplishing this mission.
Now... you can say they should not have give me this job, and you can say that I own the salary I made to the people here that helped me survive there and begin a nice career.
I say you are right.
I try to continue this "pass it over" (I think there is a cute movie with this name) and help others.
I know that my LIFE could take a different path, and I don't think that it could be too good... without the good will of so many angles that helped me whenever I needed them.
It may be only code for you – but for me it's a big deal
Thank you and the other angles for your help
Nobody likes to look stupid or lazy - sometimes you simply need some help - you are not smart enough, you don't have time, you had a bad day...
If you don't want to help - DONT
But I want to believe you do
Please check this sample project (Just I created for you). It may help you to know how to connect.
Note: I am a learner like you.
Sweetie.
Thank u for ur help...........i did same thing in my project module as u did in module........
sweetie i will try this again and let u know about this thank u very much...
iam very new to VB hence i get so many doubts and questions. sometime if i search in vb books i don't find exact answer so, i seek help from u people
Thank u for ur help...........i did same thing in my project module as u did in module........sowmya s
Just change the database name in the module;
Instead of Soumya.mdb to your database name:
And in the Form_Load event, change table name Address to your table name:
Code:
Private Sub Form_Load()
Call data_connect
rs.Open "Select * from Address Order By Name", db, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.MoveFirst
lblrecords.Caption = "Record " & rs.AbsolutePosition & " of " & rs.RecordCount
End If
show_rec
txt_lock
End Sub
If you don't want to add navigation buttons on form, then there is no need of the following code in Form_Load event.
Code:
If Not rs.EOF Then
rs.MoveFirst
lblrecords.Caption = "Record " & rs.AbsolutePosition & " of " & rs.RecordCount
End If
In one of my post to your reply i think i was harsh enough to annoy not only you but some other members also. Pls dont mind that and believe me, my intentions were not to harass you in any case nor to show that you dont know anything or so... what i intended was if you r having a feeling of getting the perfect solutions from the forum, then pls change your attitude as this will be harmful for you in future thats all.
still if you feel bad for that i appologize, if i have hurt you in any case.
again you r most welcome to put your doubts and problems forward to get solns, as we too improve with every solutions we provide.
and dear giladasaf,
there is nothing like if you dont want to help then DONT...
buddy if we know we must share this is what i feel and follow in life, but if some learns from what you know it really gives you satisfaction. well no explaination herafter buddies... enjoy coding and learning...
Hope you guys will take it positively,
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.