⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 教务系统dataset.designer.cs

📁 C sharp连接数据库的实例
💻 CS
📖 第 1 页 / 共 3 页
字号:
                    this.Adapter.DeleteCommand.Connection = value;
                }
                if ((this.Adapter.UpdateCommand != null)) {
                    this.Adapter.UpdateCommand.Connection = value;
                }
                for (int i = 0; (i < this.CommandCollection.Length); i = (i + 1)) {
                    if ((this.CommandCollection[i] != null)) {
                        ((System.Data.SqlClient.SqlCommand)(this.CommandCollection[i])).Connection = value;
                    }
                }
            }
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        protected System.Data.SqlClient.SqlCommand[] CommandCollection {
            get {
                if ((this._commandCollection == null)) {
                    this.InitCommandCollection();
                }
                return this._commandCollection;
            }
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        public bool ClearBeforeFill {
            get {
                return this._clearBeforeFill;
            }
            set {
                this._clearBeforeFill = value;
            }
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        private void InitAdapter() {
            this._adapter = new System.Data.SqlClient.SqlDataAdapter();
            System.Data.Common.DataTableMapping tableMapping = new System.Data.Common.DataTableMapping();
            tableMapping.SourceTable = "Table";
            tableMapping.DataSetTable = "学生";
            tableMapping.ColumnMappings.Add("学号", "学号");
            tableMapping.ColumnMappings.Add("姓名", "姓名");
            tableMapping.ColumnMappings.Add("专业", "专业");
            tableMapping.ColumnMappings.Add("宿舍", "宿舍");
            this._adapter.TableMappings.Add(tableMapping);
            this._adapter.DeleteCommand = new System.Data.SqlClient.SqlCommand();
            this._adapter.DeleteCommand.Connection = this.Connection;
            this._adapter.DeleteCommand.CommandText = "DELETE FROM [dbo].[学生] WHERE (([学号] = @Original_学号) AND ([姓名] = @Original_姓名) AND" +
                " ([专业] = @Original_专业) AND ([宿舍] = @Original_宿舍))";
            this._adapter.DeleteCommand.CommandType = System.Data.CommandType.Text;
            this._adapter.DeleteCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_学号", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "学号", System.Data.DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_姓名", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "姓名", System.Data.DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_专业", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "专业", System.Data.DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_宿舍", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "宿舍", System.Data.DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.InsertCommand = new System.Data.SqlClient.SqlCommand();
            this._adapter.InsertCommand.Connection = this.Connection;
            this._adapter.InsertCommand.CommandText = "INSERT INTO [dbo].[学生] ([学号], [姓名], [专业], [宿舍]) VALUES (@学号, @姓名, @专业, @宿舍);\r\nSEL" +
                "ECT 学号, 姓名, 专业, 宿舍 FROM 学生 WHERE (学号 = @学号)";
            this._adapter.InsertCommand.CommandType = System.Data.CommandType.Text;
            this._adapter.InsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学号", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "学号", System.Data.DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@姓名", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "姓名", System.Data.DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@专业", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "专业", System.Data.DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@宿舍", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "宿舍", System.Data.DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand = new System.Data.SqlClient.SqlCommand();
            this._adapter.UpdateCommand.Connection = this.Connection;
            this._adapter.UpdateCommand.CommandText = "UPDATE [dbo].[学生] SET [学号] = @学号, [姓名] = @姓名, [专业] = @专业, [宿舍] = @宿舍 WHERE (([学号]" +
                " = @Original_学号) AND ([姓名] = @Original_姓名) AND ([专业] = @Original_专业) AND ([宿舍] =" +
                " @Original_宿舍));\r\nSELECT 学号, 姓名, 专业, 宿舍 FROM 学生 WHERE (学号 = @学号)";
            this._adapter.UpdateCommand.CommandType = System.Data.CommandType.Text;
            this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学号", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "学号", System.Data.DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@姓名", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "姓名", System.Data.DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@专业", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "专业", System.Data.DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@宿舍", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "宿舍", System.Data.DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_学号", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "学号", System.Data.DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_姓名", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "姓名", System.Data.DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_专业", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "专业", System.Data.DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_宿舍", System.Data.SqlDbType.Char, 0, System.Data.ParameterDirection.Input, 0, 0, "宿舍", System.Data.DataRowVersion.Original, false, null, "", "", ""));
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        private void InitConnection() {
            this._connection = new System.Data.SqlClient.SqlConnection();
            this._connection.ConnectionString = global::教务系统.Properties.Settings.Default.教务系统ConnectionString;
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        private void InitCommandCollection() {
            this._commandCollection = new System.Data.SqlClient.SqlCommand[1];
            this._commandCollection[0] = new System.Data.SqlClient.SqlCommand();
            this._commandCollection[0].Connection = this.Connection;
            this._commandCollection[0].CommandText = "SELECT 学号, 姓名, 专业, 宿舍 FROM dbo.学生";
            this._commandCollection[0].CommandType = System.Data.CommandType.Text;
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Fill, true)]
        public virtual int Fill(教务系统DataSet.学生DataTable dataTable) {
            this.Adapter.SelectCommand = this.CommandCollection[0];
            if ((this.ClearBeforeFill == true)) {
                dataTable.Clear();
            }
            int returnValue = this.Adapter.Fill(dataTable);
            return returnValue;
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public virtual 教务系统DataSet.学生DataTable GetData() {
            this.Adapter.SelectCommand = this.CommandCollection[0];
            教务系统DataSet.学生DataTable dataTable = new 教务系统DataSet.学生DataTable();
            this.Adapter.Fill(dataTable);
            return dataTable;
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
        public virtual int Update(教务系统DataSet.学生DataTable dataTable) {
            return this.Adapter.Update(dataTable);
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
        public virtual int Update(教务系统DataSet dataSet) {
            return this.Adapter.Update(dataSet, "学生");
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
        public virtual int Update(System.Data.DataRow dataRow) {
            return this.Adapter.Update(new System.Data.DataRow[] {
                        dataRow});
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
        public virtual int Update(System.Data.DataRow[] dataRows) {
            return this.Adapter.Update(dataRows);
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Delete, true)]
        public virtual int Delete(string Original_学号, string Original_姓名, string Original_专业, string Original_宿舍) {
            if ((Original_学号 == null)) {
                throw new System.ArgumentNullException("Original_学号");
            }
            else {
                this.Adapter.DeleteCommand.Parameters[0].Value = ((string)(Original_学号));
            }
            if ((Original_姓名 == null)) {
                throw new System.ArgumentNullException("Original_姓名");
            }
            else {
                this.Adapter.DeleteCommand.Parameters[1].Value = ((string)(Original_姓名));
            }
            if ((Original_专业 == null)) {
                throw new System.ArgumentNullException("Original_专业");
            }
            else {
                this.Adapter.DeleteCommand.Parameters[2].Value = ((string)(Original_专业));
            }
            if ((Original_宿舍 == null)) {
                throw new System.ArgumentNullException("Original_宿舍");
            }
            else {
                this.Adapter.DeleteCommand.Parameters[3].Value = ((string)(Original_宿舍));
            }
            System.Data.ConnectionState previousConnectionState = this.Adapter.DeleteCommand.Connection.State;
            if (((this.Adapter.DeleteCommand.Connection.State & System.Data.ConnectionState.Open) 
                        != System.Data.ConnectionState.Open)) {
                this.Adapter.DeleteCommand.Connection.Open();
            }
            try {
                int returnValue = this.Adapter.DeleteCommand.ExecuteNonQuery();
                return returnValue;
            }
            finally {
                if ((previousConnectionState == System.Data.ConnectionState.Closed)) {
                    this.Adapter.DeleteCommand.Connection.Close();
                }
            }
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
        public virtual int Insert(string 学号, string 姓名, string 专业, string 宿舍) {
            if ((学号 == null)) {
                throw new System.ArgumentNullException("学号");
            }
            else {
                this.Adapter.InsertCommand.Parameters[0].Value = ((string)(学号));
            }
            if ((姓名 == null)) {
                throw new System.ArgumentNullException("姓名");
            }
            else {
                this.Adapter.InsertCommand.Parameters[1].Value = ((string)(姓名));
            }
            if ((专业 == null)) {
                throw new System.ArgumentNullException("专业");
            }
            else {
                this.Adapter.InsertCommand.Parameters[2].Value = ((string)(专业));
            }
            if ((宿舍 == null)) {
                throw new System.ArgumentNullException("宿舍");
            }
            else {
                this.Adapter.InsertCommand.Parameters[3].Value = ((string)(宿舍));
            }
            System.Data.ConnectionState previousConnectionState = this.Adapter.InsertCommand.Connection.State;
            if (((this.Adapter.InsertCommand.Connection.State & System.Data.ConnectionState.Open) 
                        != System.Data.ConnectionState.Open)) {
                this.Adapter.InsertCommand.Connection.Open();
            }
            try {
                int returnValue = this.Adapter.InsertCommand.ExecuteNonQuery();
                return returnValue;
            }
            finally {
                if ((previousConnectionState == System.Data.ConnectionState.Closed)) {
                    this.Adapter.InsertCommand.Connection.Close();
                }
            }
        }
        
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public virtual int Update(string 学号, string 姓名, string 专业, string 宿舍, string Original_学号, string Original_姓名, string Original_专业, string Original_宿舍) {
            if ((学号 == null)) {
                throw new System.ArgumentNullException("学号");
            }
            else {
                this.Adapter.UpdateCommand.Parameters[0].Value = ((string)(学号));
            }
            if ((姓名 == null)) {
                throw new System.ArgumentNullException("姓名");
            }
            else {
                this.Adapter.UpdateCommand.Parameters[1].Value = ((string)(姓名));
            }
            if ((专业 == null)) {
                throw new System.ArgumentNullException("专业");
            }
            else {
                this.Adapter.UpdateCommand.Parameters[2].Value = ((string)(专业));
            }
            if ((宿舍 == null)) {
                throw new System.ArgumentNullException("宿舍");
            }
            else {
                this.Adapter.UpdateCommand.Parameters[3].Value = ((string)(宿舍));
            }
            if ((Original_学号 == null)) {
                throw new System.ArgumentNullException("Original_学号");
            }
            else {
                this.Adapter.UpdateCommand.Parameters[4].Value = ((string)(Original_学号));
            }
            if ((Original_姓名 == null)) {
                throw new System.ArgumentNullException("Original_姓名");
            }
            else {
                this.Adapter.UpdateCommand.Parameters[5].Value = ((string)(Original_姓名));
            }
            if ((Original_专业 == null)) {
                throw new System.ArgumentNullException("Original_专业");
            }
            else {
                this.Adapter.UpdateCommand.Parameters[6].Value = ((string)(Original_专业));
            }
            if ((Original_宿舍 == null)) {
                throw new System.ArgumentNullException("Original_宿舍");
            }
            else {
                this.Adapter.UpdateCommand.Parameters[7].Value = ((string)(Original_宿舍));
            }
            System.Data.ConnectionState previousConnectionState = this.Adapter.UpdateCommand.Connection.State;
            if (((this.Adapter.UpdateCommand.Connection.State & System.Data.ConnectionState.Open) 
                        != System.Data.ConnectionState.Open)) {
                this.Adapter.UpdateCommand.Connection.Open();
            }
            try {
                int returnValue = this.Adapter.UpdateCommand.ExecuteNonQuery();
                return returnValue;
            }
            finally {
                if ((previousConnectionState == System.Data.ConnectionState.Closed)) {
                    this.Adapter.UpdateCommand.Connection.Close();
                }
            }
        }
    }
}

#pragma warning restore 1591

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -