First, I would thank all the Daniweb team for making this useful site available for us.
I'm developing with mysql database. I always declared the details about the database I use at the top of every form. I mean, the database name,username,password and everything about it. We know this will not be great when I deploy my app to other computers. I would like to know the best way to save these credentials and allow someone to set them after installling the app (like how it is done with other apps). May be saving them to a text (.txt) file?
How do I save the details/variables to a text file?
How do I read/call these variables to my forms?
P.S: I have read this discussion but everything was strange to me!

I will appreciate any help. Also if there is anything I should read online.

Edited 3 Years Ago by savedlema

I'm going to make a few assumptions

  • the database will always be MS SQL
  • the database name will never change
  • the security type will be integrated security

based on those assumptions, the only thing you should ever have to modify from installation to installation is the SQL Server Name. If the server type will always be SQLEXPRESS then you don't even have to modufy that. However, let's assume that the sever name will change. Iin that case you can create an application level settings variable and set it to "" by default. When the app runs you can test for this and prompt accordingly. Something like

serverName = My.Settings.ServerName

If serverName = "" Then
    'prompt for serverName and copy it into the connection string
    'if you can open a connection to the database then
        My.Settings.ServerName = serverName
    'else
        MsgBox("Could not connect to server " & serverName)
        Me.Close()
    'end if
End If

Then the next time the app runs it will automatically get serverName entered on the last run. If you are using a username/password for authentication then you may have to prompt for those as well.

Thanks Rev. But, I think you must have forgot in my question I stated I'm using mysql (Mysql Workbench 5.2). Does it make any difference?

Sorry about that. Old eyes and interference from an overly affectionate cat. I must have misread MySql as MsSql. I'm not familiar with MySql but the principle is the same. You can prompt for the server name (and possibly credentials), then save it (once you verify that you can connect to the database) for future use.

Edited 3 Years Ago by Reverend Jim

Rev, I was able to do a lot with Application Settings. But, I realize that, if I use 'user scope', these settings will not be there when the app is restarted, so a user will need to fill them everytime the app is started (okay??)

But, I would like for these settings to be stored somewhere and allow the user to change them whenever needed (may be we changed the mysql server/its IP Address/e.t.c)
I think then this has to be in 'application scope' settings, but VB says they are "Read Only". How do I do this?

I want like, I remember I once installed a library app that asked for database path only the first time it was run. I think you get me.
P.S: I also thought it would be a good idea to start another discussion here

I will appreciate any help on this, or any alternatives.

This article has been dead for over six months. Start a new discussion instead.