-
I have a question that i would like some help. I normally use ADODB to connect to access db. The problem is that i have to create a connection in every form module including the full path of the database in my PC. If i happen to change the db path then it would mean i have to alter all my connections in the database. i would like to know if their is a better way that i can use to create my connection only once in my application to make things easier.
-
hi,
You can store your connection string in a Database Table Field. else you can also store the same in your web.config, if you are working on a web application. And you can call it where ever you want.
Regards,
Royal
-
That's sounds complex for me, would you mind an example please?
-
Hi
Is this web or windows based? DotNet?
I use connections to SQLServer and store the details in an XML config file. There are various ways to store and retrieve the information, but it makes it easy to change the details as no code changes are required.
-
It is not a web based application, it's a standalone vb6 application.
-
' Set properties of the DataGrid control.
Me.DataGrid1.AllowAddNew = False
Me.DataGrid1.AllowDelete = False
Me.DataGrid1.AllowUpdate = False
' Set properties of the AOD Data Control.
Me.Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\DB2.mdb"
Me.Adodc1.RecordSource = "SELECT * FROM House"
'Link the DataGrid control to the AOD Data control.
Set Me.DataGrid1.DataSource = Me.Adodc1
that is the code i use to conntect a database using a ADOC
-
hi depash
1. create one method in another page(which gives connection string)
2. create object to that page ....
3. when ever u want call that method through this object..............
4. some thing like this...................
this is in vb.net
page1: your page where u want to access databse
---some code---
dim obj as page2
dim conString as connectionString
obj =new page2 //creating object
constring=page2.getConnectionString()
page2: //vb file
class page2
begin
public function getConnectionString() as string
dim str as string="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" \DB2.mdb"
return str
end function
End
i hope this helps
-
put the following code in a module and replace databaseName with your database. In every form you want to connect to database just **call connectDatabase** and use your record set to manipulate your data.
Public cnn As Connection
Public rs As Recordset
---------------------------------------------------------------------
Public Sub connectDatabase()
Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.JET.OLEDB.4.0"
.ConnectionString = App.Path & "\databaseName.mdb"
.Open
End With
End Sub
-
Thanks alot all of you, i used your suggestions and now i connect using the CALL statement which is what i just needed. You are an asset to me.
-
web config
[paslanmaz](http://www.paslanmazbul.net/)
[evden eve nakliyat](http://www.evdenevenakliyatbul.com/)
[bul](http://www.paslanmazbul.net/)
-
-
error post you page
-
error post you page
Enter your message below
Sign in or Join us (it's free).