ADO.NET中的sql连接
using System.Data; // Use ADO.NET namespace
using System.Data.SqlClient;
SqlConnection thisConnection = new SqlConnection(
@"Data Source=GY; Initial Catalog=northwind;uid=sa;password=datadog"); //先建立连接
thisConnection.Open();//打开连接
SqlCommand thisCommand = thisConnection.CreateCommand();//直接指定conn的command
也可以这样 // SqlCommand cmd = new SqlCommand();
// cmd.Connection = thisConnection;
cmmand的sql命令
thisCommand.CommandText = "SELECT CustomerID, CompanyName from Customer";
SqlDataReader thisReader = thisCommand.ExecuteReader();//sqldatareader不可以用new 必须直接与command关联
//用reader读出表
while (thisReader.Read())
{
// Output ID and name columns
Console.WriteLine("\t{0}\t{1}",
thisReader["CustomerID"], thisReader["CompanyName"]);
// Close reader 用完要关闭
thisReader.Close();
相关文档:
1: /*
2: 通过SQL 语句备份数据库
3: */
4: BACKUP DATABASE mydb
5: TO DISK ='C:\DBBACK\mydb.BAK'
6: --这里指定需要备份数据库的路径和文件名,注意:路径的文件夹是必须已经创建的.文件名可以使用日期来标示
7:
8: /*
9: 通过SQL语句还原数据库
10: */
11: USE ma ......
第一次安装2005,花了不少精力。虽然没什么太难的,但是不知道的话会很棘手的。如果你正在安装,并且发现这篇文章,那么你很走运,你将会顺利的安装成功。
安装目录中包含Sql Server x64 和 x86, x86是32位机器的。x86中又有tools 和 Servers 。第一次安装了Servers,然 ......
public class SqlCheck
{
public SqlCheck()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public SqlConnection oconn()
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["StudyConnectionString"] ......
在计算机中数据有两种特征:类型和长度。所谓数据类型就是以数据的表现方式和存储方式来划分的数据的种类。在SQL Server 中每个变量、参数、表达式等都有数据类型。 其中,BIGINT、 SQL_VARIANT 和TABLE 是SQL Server 2000 中新增加的3 种数据类型.
一、 整数数据类型
&nb ......