|
You could ignore the one in the config file and hard-code the one you want.
You may be able to encrypt the one in the config file.
It's probably best to leave it the way it is and not change anything unless it becomes a problem.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Yes , it's become a problem because users that don't know what they are doing , can open it and change the information.
So I want to know how can I create on runtime?
Thank you !
|
|
|
|
|
dilkonika wrote: it's become a problem because users that don't know what they are doing , can open it and change the information. That's a nonsense-argument.
There's more important things on the PC that they could break by accident. There's also no real way to abuse the information in the string. Stop being paranoid and come back if you got a good argument for hiding it.
dilkonika wrote: So I want to know how can I create on runtime? It's a string;
Dim MyString As String = "Hello World"
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you !
To be honest , I have 2 reasons why I want to create the connection string on runtime :
First : it's for security measure to not let users change the file.
Second : I'm making some changes in application and there are situations when a users can work with a local sql server database.And there are situations that they should work with a database (has the same structure as the local database) but on another server in network.
I know it's a string but does it have a specific structure ?
Or should I copy paste from the connection string that is inside app.config ?
Thank you !
|
|
|
|
|
If your application is under any path under Program Files, normal users cannot change the connection string. Well, they can load the .config file into Notepad, but they cannot save it.
Now, if your users are Administrators, well, there's nothing you can do to stop them.
Honestly, it's a waste of time to try and protect the connection string. If they want to screw with the app and ruin their data, that's their problem.
dilkonika wrote: I know it's a string but does it have a specific structure ?
The "structure" as you put it depends entirely on the database engine you're connecting to, the client (if any) you're using and the connection technology. Go to ConnectionStrings.com for the definitive list of connection string possibilities.
|
|
|
|
|
Thank you !
ok , let's forget the first reason.
but what about the second reason , it's possible to connect to another database on another server with app.config file ?
if there's please help me with some information.
Thank you !
|
|
|
|
|
You can put a mostly configured connection string in the app.config. This "template" connection string can have replaceable tags in it to put in a server\instance name and a database name. When you need the connection string, load it (ConfigurationManager class), replace the tags with the appropriate names (it is just a string afterall) and then you can use that in your database code.
|
|
|
|
|
Thank you !
I can do that , but in this case what is the purpose of app.config file , just to keep a string that I read and I change in runtime.It's the same with the case i construct the entire connection string during runtime.
Or is better to change the replaceable tags directly to app.config file and keeping the Dbcontext unchanged without passing the connection string as parameter ? Is possible this ?
Thank you !
|
|
|
|
|
Don't change the tags in the app.config file. Users cannot change anything in Program Files, so your code will not be able to change it either.
Code always runs AS THE USER that launched it.
|
|
|
|
|
Thank you !
But my application folder isn't on Program files.
The folder is c:\MyProgram.
So in this case do you think that I can change the app.config file ?
Thank you !
|
|
|
|
|
System Admins don't like that, so if you're deploying your app in a corporate environment, I'd think twice about that.
|
|
|
|
|
No problem about this .
My question is simple : Is there a problem to change the content on app.config ? If yes this file should be treated as text file during manipulation ?
Thank you !
|
|
|
|
|
No, but it's just an XML file.
But, once you replace the tags in the app.config file, you don't have known tags to look for any more.
|
|
|
|
|
dilkonika wrote: can open it
"Can" and "do" are very different things. If they don't then it's not a problem.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Is it possible to create an ODBC Connection for MySql Database using VB .net?
I have searched the net but could not find any information
|
|
|
|
|
can you not use the MySql Connector[^]?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Absolutely. I have to use the connector but I am not sure of the code. So in case and link to some sample is available it will be of great help
|
|
|
|
|
It's usually the installer that registers the ODBC connection; has to be done once, not at every start of your app.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Very true. I actually want to put an installer which creates the ODBC Connection. But I am not getting any sample of the code. In case anybody has any link it will be a great help for me
|
|
|
|
|
SPSandy wrote: I am not getting any sample of the code MSDN[^] again, example at the bottom of the page. It's the same pattern as the SqlConnection/SqlCommand examples; create a connection, execute a command with parameters, and read the results.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello !
I'm using vb.net with sql server. On a foler I have a backup database that is empty (model.bak).How can I do to restore this database with a new name ( DB1) from code in visual basic 2013 ?
Thank you !
|
|
|
|
|
dilkonika wrote: How can I do to restore this database with a new name ( DB1) from code in visual basic 2013 ? One could execute a RESTORE[^]-command with the appropriate parameters. Alternatively, you can use SMO.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello !
Where can I find some information about doing this process with SMO ?
Because I want to learn both methods.
Thank you !
|
|
|
|
|
dilkonika wrote: Where can I find some information about doing this process with SMO ? There's article's here[^] on CodeProject, and there's examples on TechNet[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
On your opinion , is better to use Transact-SQL or SMO ?
For example :
I'm creating and testing my application on Visual Studio2013 and SQL server 2008R2.
If I need to run my program on SQL server 2005 or SQL server 2012 , will SMO work ?
Thank you !
|
|
|
|