I have my connection string stored in App.Config
<connectionStrings>
<clear />
<add name="CTaC_Information_System.Properties.Settings.CIS_beConn"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source="\serverfileCIS DataDatabaseCIS_be.accdb"e;;Jet OLEDB:Database Password=123"
providerName="System.Data.OleDb" />
Then when I go to my main.xaml.cs I type in the following:
string cisconn = ConfigurationManager.ConnectionStrings["CTaC_Information_System.Properties.Settings.CIS_beConn"].ConnectionString;`
I found that answer on Stack Overflow when searching, but some were say to put var
but when I typed var
it wouldn't recognize it so I went with the string
method.
When I go to type cisconn.Open();
the option isn't there. I am referencing System.Configuartion;
,System.Data.Sql;
System.Data.SqlClient;
and System.Data.OleDb;
.
Can someone show / tell me how I can connect to the database from c#? I'm trying to test the connection when my application runs but I can't figure it out.
See Question&Answers more detail:os