How to create a dynamic property for a connectionstring variable only ??

  • 14 years ago

    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

     

     

     

     

     

     

  • 14 years ago

    Mostly I prefer to create INI file in format:

    [ValueName]
    ValueValue






  • 14 years ago

    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....

  • 14 years ago

    Hi,

    Connection object of what?

  • 14 years ago

    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?

  • 14 years ago
    Possible. but dont know how to explain in english. my english so terrible... sorry 4 that

  • 14 years ago

    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..

  • 14 years ago
    here what i can said (if u can understand):

    just imagine that u have 2 object involved in this case.
    • Page
    • Module
    Page Object:
    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
             PAGE.ConnectionString = MODULE.ConnectionString

    after this line u can make a connection to string.....








    that all i can said, if u can understand.... :)Smiley Face [:)]




















  • 14 years ago
    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.



  • 14 years ago

    Well i couldn't able to understand your idea. May be better you rewrite it so that to grap your idea vividly.

     

  • 14 years ago

    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.

  • 14 years ago

    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

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are only 3 numbers of interest to a computer scientist: 1, 0 and infinity”