sqlConnection 只提供对数据库的连接要想对数据库进行操作还得用sqlCommand控件
打开 工具箱 把sqlConnection 和 sqlCommand 控件拖到工作区中 生成了sqlConnection1和sqlCommand1 右击sqlConnection1选中 属性 在它的属性列表中有ConnectionString点击下拉键头然后点 新建连接 在弹出的 数据连接属性 中配置好数据连接 确定返回,查看sqlCommand1属性 在Connetion 中点击下拉箭头选现有就可以了
代码如下
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=\"915-13\";packet size=4096;user id=sa;data source=306DUOMEITI;persi" +
"st security info=False";
//
// sqlCommand1
//
this.sqlCommand1.Connection = this.sqlConnection1;
打开 工具箱 把sqlConnection 和 sqlCommand 控件拖到工作区中 生成了sqlConnection1和sqlCommand1 右击sqlConnection1选中 属性 在它的属性列表中有ConnectionString点击下拉键头然后点 新建连接 在弹出的 数据连接属性 中配置好数据连接 确定返回,查看sqlCommand1属性 在Connetion 中点击下拉箭头选现有就可以了
代码如下
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=\"915-13\";packet size=4096;user id=sa;data source=306DUOMEITI;persi" +
"st security info=False";
//
// sqlCommand1
//
this.sqlCommand1.Connection = this.sqlConnection1;
解决方案 »
- web的cs文件弹出窗口问题
- WinForm里怎样用C#使Label及其里面文字的大小随窗口大小成比例进行变化?
- 求助一个关于string[]的问题
- 使用xaml语言开发时,遇到一问题敬请帮忙,....急啊!
- 有没有办法删除xml节点的命名空间
- 关于OleDbDataReader读取ACCESS顺序错乱的问题
- .NET中用C#语言实现http参数传递的问题,及相关接口的实现
- 局域网里,知道了IP地址,怎么获得主机名呀,求助!拜谢!
- 请问 a = b + (b = a) * 0;是怎么执行的?
- C#中有没有整数的集合类
- ACCESS数据库图片更新的问题(有经验者进)
- 有人能给出具体的水晶报表的实例吗?(本人刚注册,没分给不介意的朋友帮个忙,十万着急中!)
/// 公共连接
/// </summary>
private sqlConnection _Conn = new sqlConnection();
/// <summary>
/// 获取erp公共连接
/// </summary>
public sqlConnection Conn
{
get
{
if (_Conn.ConnectionString =="") return initConn();
else return _Conn;}
set { value = initConn(); }
}
private sqlConnection initConn()
{
_Conn = new OracleConnection(System.Configuration.ConfigurationManager.ConnectionStrings["erpConn"].ToString());
if (_Conn.State != ConnectionState.Open) _Conn.Open();
return _Conn;
}
http://www.cnblogs.com/singlepine/archive/2005/10/15/255374.html