0
How ways have connection sql to c#?
have different ways for connection sql to c#,better and simple ways is link but yet not finished because link have defferent methods that connection sql to c#.thank you for reading.âșâș
11 Answers
+ 1
yes.but your code even string.
0
This is one way.
https://www.sololearn.com/Discuss/735354/how-do-i-add-a-database-to-an-application-using-a-language
In c# use a sqlconnection with a sqlcommand and a sqldatareader
0
you most go app config and you most writing
connectionStrung instruction in appconfig.
0
Do you have a sql-server running ? You can set the connection string in code if you are testing.
0
yes. you want what is code?
0
Are you looking for these
http://www.dofactory.com/reference/connection-strings
Microsoft Sql Express
.NET Data Provider -- Default Relative Path -- Standard Connection
using System.Data.SqlClient;
var conn = new SqlConnection();
conn.ConnectionString =
"Data Source=.\SQLExpress;" +
"User Instance=true;" +
"User Id=UserName;" +
"Password=Secret;" +
"AttachDbFilename=|DataDirectory|DataBaseName.mdf;"
conn.Open();
0
my command is simple than it bicusse if you want set your saftware another pc you must change db name in appconfig but your ways you most change code into .net form another pc.you undrestand meâș
0
What is your question ?
You ask how to connect to a database.
This is the most simple way to do it.
Ofcourse if you want to change the datsbase without recompiling it needs to be in the appconfig and it can be as string.
0
??? I do not understand you.
Are you looking for this.
https://www.dotnetperls.com/settings
Create a setting in the settings screen. Give it a default value and use the value with this code.
Properties.Settings.Default.MyString;
0
no.these not