c# - Which Namespaces Must Be Used to Connect to SQL Server with ADO.NET? -


i using example connect c# sql server. can please tell me have include in order able use sqlconnection?

it must like: using sqlconnection; ???

string connectionstring = @"data source=.\sqlexpress;attachdbfilename=""c:\sql server 2000 sample databases\northwnd.mdf"";integrated security=true;connect timeout=30;user instance=true"; sqlconnection sqlcon = new sqlconnection(connectionstring);  sqlcon.open();  string commandstring = "select * customers";  sqlcommand sqlcmd = new sqlcommand(commandstring, sqlcon);  sqldatareader datareader = sqlcmd.executereader();  while (datareader.read())  {    console.writeline(string.format("{0} {1}", datareader["companyname"], datareader["contactname"]));  }  datareader.close();  sqlcon.close(); 

using system.data; using system.data.sqlclient; 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -