C#中最简单的问题

来源:百度知道 编辑:UC知道 时间:2024/05/27 11:17:29
this.sqlConnection1=newSqlConnection(HotelManage.DataLevel.Connection.ConnString);
this.sqlCommand1=new SqlCommand();
this.sqlCommand1.CommandType=CommandType.Text; this.sqlCommand1.Connection=this.sqlConnection1;
this.sqlCommand2=new SqlCommand();
this.sqlCommand2.CommandType=CommandType.StoredProcedure;
this.sqlCommand2.Connection=this.sqlConnection1;
这些都什么意思

this.sqlConnection1=newSqlConnection(HotelManage.DataLevel.Connection.ConnString);
实例化一个数据库连接。
this.sqlCommand1=new SqlCommand();
实例化一个数据库操作
this.sqlCommand1.CommandType=CommandType.Text;
sql操作命令为文本类型
this.sqlCommand1.Connection=this.sqlConnection1;
数据库操作实例连接上数据库(前面应该漏了一句this.sqlConnection1.Open(),否则执行不了)
this.sqlCommand2=new SqlCommand();
又实例化一个数据库操作实例
this.sqlCommand2.CommandType=CommandType.StoredProcedure;
sql操作命令类型为存储过程
this.sqlCommand2.Connection=this.sqlConnection1

你那么多this干什么,没必要

数据库连接 还有使用数据库的数据形式 你的语句用的是存储过程

你什么问题