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.☺☺

2nd Oct 2017, 10:47 PM
MahdiRahim-zadeh
11 Réponses
+ 1
yes.but your code even string.
3rd Oct 2017, 8:15 PM
MahdiRahim-zadeh
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
3rd Oct 2017, 7:27 PM
sneeze
sneeze - avatar
0
you most go app config and you most writing connectionStrung instruction in appconfig.
3rd Oct 2017, 7:47 PM
MahdiRahim-zadeh
0
Do you have a sql-server running ? You can set the connection string in code if you are testing.
3rd Oct 2017, 7:50 PM
sneeze
sneeze - avatar
0
yes. you want what is code?
3rd Oct 2017, 7:54 PM
MahdiRahim-zadeh
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();
3rd Oct 2017, 7:58 PM
sneeze
sneeze - avatar
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☺
3rd Oct 2017, 8:05 PM
MahdiRahim-zadeh
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.
3rd Oct 2017, 8:10 PM
sneeze
sneeze - avatar
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;
3rd Oct 2017, 8:19 PM
sneeze
sneeze - avatar
0
no.these not
3rd Oct 2017, 8:35 PM
MahdiRahim-zadeh