By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,955 Members | 1,793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,955 IT Pros & Developers. It's quick & easy.

Where To Write The Connection String

chandru8
100+
P: 145
Hi everybody

Can anyone suggest me where to write the connection string
because am writing the connection string in each form load closing it in form_unload

the problem is when i want to change the path mean i need to change the in change

is there any alternative

thanks in advance
Apr 22 '08 #1
Share this Question
Share on Google+
3 Replies


debasisdas
Expert 5K+
P: 8,127
write that in a module or can use the load event of MDI form for the purpose.
Apr 22 '08 #2

chandru8
100+
P: 145
I Have Written The Connection Open In The Module
For Executing The Query I Used Set Module1.rs = Connection.execute(string )

Is It Correct

NOW I TRIED WRITTING INT THE MDI FORM
BUT THE QUERY WHICH I WROTE IN THE FORM IS NOT WORKING
------------------------MDI FORM
DIM objCon As New ADODB.Connection
DIM rs As New ADODB.Recordset
DIM strSql As String

Private Sub MDIForm_Load()
objCon.ConnectionString = "Provider = Microsoft.jet.oledb.4.0;Data source = C:\Crd.mdb"
objCon.Open
End Sub

Private Sub MDIForm_Unload(Cancel As Integer)
objCon.Close
Set objCon = Nothing
End Sub
------------------------FORM
strSql = "SELECT * FROM Login INNER JOIN MappingStatus ON Login.UserName = MappingStatus.Username WHERE (((Login.UserName)='" & txtUserName.Text & "'));"
Set rs = objCon.Execute(strSql)
Apr 22 '08 #3

debasisdas
Expert 5K+
P: 8,127
declare the connection in module.

open /close in form.

remove the semicolon from SQL statement.
Apr 22 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.