.net2005连接数据库
Data Source=PC-200808301549;Initial Catalog=Northwind;Integrated Security=True这个是在连接数据库的什么时候用的。。最好能写过例子 --------------------编程问答--------------------
using System;--------------------编程问答-------------------- string strconn="server=PC-200808301549;Initial Catalog=Northwind;Integrated Security=True"
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
string strConn = "Server=机器名或ip;uid=sa;pwd=密码;database=master";
using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(strConn))
{
conn.Open();
using (System.Data.SqlClient.SqlCommand command = conn.CreateCommand())
{
command.CommandText = "select * from sysobjects";
using (System.Data.SqlClient.SqlDataAdapter adp = new System.Data.SqlClient.SqlDataAdapter(command))
{
System.Data.DataSet ds = new System.Data.DataSet();
adp.Fill(ds);
Console.WriteLine(ds.GetXml());
Console.Read();
}
}
conn.Close();
}
}
}
}
SqlConnection conn = new SqlConnection(strconn); --------------------编程问答-------------------- 接楼上的..
conn.open();
关闭的话
conn.close();
--------------------编程问答-------------------- --------------------编程问答-------------------- 这个一般设置为全局的
每次链接数据库需要打开时就调用它 --------------------编程问答--------------------
string strconn="server=PC-200808301549;Initial Catalog=Northwind;Integrated Security=True"
SqlConnection conn = new SqlConnection(strconn);
conn.open();
补充:.NET技术 , C#