How to create a dynamic property for a connectionstring variable only ??
-
Hi everyone
I know how to create a dynamic property for a connection object string property, by droping the connection object from the toobox onto a form and creating the dynamic property from the property list is stright forward. Then simply modifying the .exe.config file is enough to change the property from the outside.
Now my Question, Is it possible to create the configuration file for a single variable connection string that i use at module level declaration. Or should i create a componet that handle this ? if so How ? I like to know if it possible to create a connection object that uses this string by code that is accessible from different forms.
In addition Is it allowed to creat manually a config files the app.confi and .....exe.confi files ?
I kindly need someone's help ! thanks
-
Mostly I prefer to create INI file in format:
[ValueName]
ValueValue -
hi,
Just tell me the idea or post me URL that explians about it. I hopw this won't take your time. I really need some idea.
please do it....
-
Hi,
Connection object of what?
-
I tried to say that if it is possible to create a dynamic property for a single variable like for example connectionstring which is declared at module without creating a componet.
If it is needed to create a componet to do this, How is it done?
-
Possible. but dont know how to explain in english. my english so terrible... sorry 4 that
-
I forgot to add for which connection object i need it for. I am trying to do it for sqlconnection object. so the connection string will be for this object..
-
here what i can said (if u can understand):
just imagine that u have 2 object involved in this case.- Page
- Module
Default propertis for whole system.
it contain field,properties,function and much more. in this case we created a field for connectionstring, i name it as ConnectionString. u can do more if u want.
Module Object:
Every module in u r sistem will have it's own object.
like said, when u created MODULE for STAFF, so u must created module object for that.
u r object model shoud have a field for connectionstring if u want to create a dynamic connection. so name it as ConnectionString.
Now u have many object that have a ConnectionString Field and one of is a default value.
How to make it:
in .NET
as a default Page.ConnectionString will take a string from .config file.
when it run a module object, system will choose with string will use like this:IF Not MODULE.ConnectionString is Nothing THEN
that all i can said, if u can understand.... :)
PAGE.ConnectionString = MODULE.ConnectionString
after this line u can make a connection to string.....
-
for me, it same wheather u use ADO,OLE,SQL or otherelse object because it inherit from same model.
what make it different is more function and more features. Just like u use ACCESS and SQL. u will c a different like some function can be use in ACCESS but not in SQL.
-
Well i couldn't able to understand your idea. May be better you rewrite it so that to grap your idea vividly.
-
Hi,
If what you want is to call the connection from different forms you can create a class something like:
Imports system.data
Imports system.data.sqlclient
Public Class SetConnectionClass
Public sub setconnection(byval cn as sqlconnection)
Cn = new sqlconnection(“some connection”)
Cn.open
End sub
End class
For calling the class just creates a new instance of the class, for example:
Dim cn as sqlconnection
Dim scnn as new SetConnectionClass
Scnn.setconnection(cn)
Other thing, you can use ODBC if what you want is to update the connection outside the project.
-
Other hand: in our cmpny we call module routines with ConnEctionString as argument, or we are initialising classes with that. So you can use that function on any connection u like... eg.:
Sub ShowListOfCustomers(cString$)
dim Con as new OleDb.OleDbConnection(cString)
...etc...End Sub
OR
Class ctrlCustomerEdit
private Con as OleDbConnection 'shared between internal procdrs
Sub New(cString$, onlyShow as boolean)
Con = New ...etc
End Sub
End Class
Post a reply
Quick links
Recent activity
- arif ahmad replied to How to receive data in web ...
- William Thompson replied to What is the name of the Win...
- Sameera Piyadigamage replied to Point of Sale Developers: H...
- Scott Carline replied to 4 x C# Developers for large...
- Rajendra Dhakal replied to Restore SQL Server text dat...
- cloud rainda replied to How to convert between TS f...
Enter your message below
Sign in or Join us (it's free).