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;
解决方案 »
- 求数组排列组合算法
- 怎么样在.net的windows空间中加入表格
- c#怎么开发微博应用
- datagridview中添加查询的功能
- 求助!C#对word的操作,将datagrid的数据保存的word文档的模板中!
- dataGrid如何在先增加一行时在第一列上自动加上行号,而在删除一行时第一列的值又自动刷新?
- 如何在Pocket PC上使用自定义控件,急,在线等!
- 急需高手解决,uploadify遇到上传比较诡异问题,报Security Error
- CPU在单个时段永远只运行一个线程??
- vs2003安装出错 在线等待!!附安装日志
- 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