Hello ,
i have a winform and some querry to save data.
i created à class(Connexion.cs) to put the connexion string.
in this class , i have to connexion:
1-DataBase For Test
2-Database for Prod
i added in the winform a combobox(value :Prod,Test).
when the user select Prod the connexion must be "Prod"
when the user select Testthe connexion must be "Test"
this is the connexion string in Connexion.cs
<pre lang="C#">
using System;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Avancement
{
class Connexion
{
public static SqlConnection cnx = new SqlConnection("Data Source = ***\\DB; Initial Catalog = <big>BD_Name</big>; Persist Security Info = True; User ID = ***; Password =***");
}
i want to pass the information to this class
the variable remplace BD_Name
so <when the="" user="" select="" prod="" connexion="" must="" be="" "prod"
public="" static="" sqlconnection="" cnx="new" sqlconnection("data="" source="***\\DB;" initial="" catalog="<big">Prod; Persist Security Info = True; User ID = ***; Password =***");
when the user select Testthe connexion must be "Test"
public static SqlConnection cnx = new SqlConnection("Data Source = ***\\DB; Initial Catalog =
Test; Persist Security Info = True; User ID = ***; Password =***");
What I have tried:
i tried to pass variable but i can find the code
i created a public string in winform("BD") to set "Prod " or "Test"
then i tried to get it from class but nothing (form1.BD)