I'm new to C# and .net and just worked with php and mysql.
to connect to sqlserver express (in visual studio 2010) with c# we should provide a connection string that has lots of formats i found on the web specially in connectionstrings.
for example in standard format :
"Data Source=myServerAddress;Initial Catalog=myDataBase;UserId=myUsername;Password=myPassword;"
what is username and password? where can i find them? are they "root" and "" like in php mysql or something else?
as mentioned , i have created a database named "db.sdf" in sqlserver express in visual studio 2012.
I'm really confused. please help.
If your database extension is SDF,you are creating SQL Server CE (Compact Edition) database file. Use this connection string
Data Source=" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\MyData.sdf;Persist Security Info=False;
OR
Data Source=MyData.sdf;Persist Security Info=False;
UPDATE 1
You need the System.Data.SqlServerCe namespace.
SqlCeConnection conn = new SqlCeConnection("Data Source=\\Mobile\\Northwind.sdf;");
conn.Open();
.
.
.
conn.Close();
From MSDN:
Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With