{"push_id":564315995,"size":1,"distinct_size":1,"ref":"refs/heads/master","head":"13083d8f1e671ce256497e48b4aef60a3ba7888c","before":"09ba2cb1cccb4b738a62ffba6f0aab0f9da401cd","commits":[{"sha":"13083d8f1e671ce256497e48b4aef60a3ba7888c","author":{"email":"46bdae3e72dc39de84d1ff2018271642d0799a03@yahoo.com","name":"amankhatri"},"message":"connection strings sqlconnection open conn\n\nGoal:\nBinding data from a database table, to a dropdownlist. use one of them,\nI prefer webform.aspx.cs\n---- here is what we do in XML file\nconfiguration>\n<connectionStrings>\n<add name=\"DB_L17ConnectionString\" connectionString=\"Data\nSource=KHATRI\\MSSQLSERVER2;Initial Catalog=DB_L17;User\nID=sa;Password=2059794842\"\nproviderName=\"System.Data.SqlClient\" />\n</connectionStrings>\n<system.web>\n<compilation debug=\"true\" targetFramework=\"4.0\" />\n</system.web>\n\n</configuration>\n\n---- and here is what we do in webform.aspx.cs file---------\nprotected void Page_Load(object sender, EventArgs e)\n{\n/*Connection string is the name of the database and the user name and\nstuff\nthis connection string is then supplied to sqlconnection class\nconnectionString = \"data source=nameof the data base or if it is on\nlocal machine type '.\";\n* database = nameof database; user id = sa; password = password for\nwindows authentications\n* you do\n* connectionString = data source=nameof the data base or if it is on\nlocal machine type '.\";\n* database = nameof database; integrated security=sspi ,\nconnectionstring is key value pair\"*/\nstring connectionString = \"data source=khatri\\\\mssqlserver2 ;database =\nDB_L17; user id=sa; password=2059794842\";\n//string connectionString = \"data source=.;database = DB_L17; integrated\nsecurity=SSPI\";\nSqlConnection conn = new SqlConnection(connectionString);\n/*or you can do SqlConnection conn = new SqlConnection()\nconn.ConnectionString = connectionString*/\n\n/*now we need sql command which we are executing , and we have to\nspecify which connection to use*/\nSqlCommand cmd = new SqlCommand(\"Select CityId, CityName, Country from\ntblCity\", conn);\n/*we need to open connection*/\nconn.Open();\n/*now we will execute the command and set it to the datasouce property\nof gridview*/\nGridView1.DataSource = cmd.ExecuteReader();\n// DropDownList1.DataSource = cmd.ExecuteReader();\n/*then bind the data */\nGridView1.DataBind();\n//  DropDownList1.DataBind();\n\n}","distinct":true,"url":"https://api.github.com/repos/amankhatri/ASP-DOT-NET/commits/13083d8f1e671ce256497e48b4aef60a3ba7888c"}]}