我道题我不会做,想请高手帮忙解决下

来源:百度知道 编辑:UC知道 时间:2024/05/28 06:42:15
3、当前数据集ds当中有两种表,表名分别为ClassInfo和StuInfo,其中ClassInfo表中有如下字段ClassID(班级编号),ClassRoom(上课教室)和Teacher(班主任),StuInfo表中有如下字段,StuID(学号),StuName(学生姓名),ClassID(班级编号)。
ClassID为ClassInfo表的主键,StuID为StuInfo表的主键,以下代码为这两张表添加外键约束,并且要求在删除更新ClassInfo表记录的时候,StuInfo表的相关记录的相关字段置空。
ForeignKeyConstraint c = new ForeighKeyConstraint(“Class_Stu”, ds.Tables[ ].Columns[ ] , ds.Tables[ ].Columns[ ]);
ds.Tables[ ].Constraints.Add( );

4、在本机数据库Northwind中有一张职工信息表,表名为EmployeeInfo,其中有如下字段EmployeeID(职工编号),EmployeeName(员工姓名),Age(年龄)。要求添加一条新记录并统计出年龄大于40岁的人数,新记录内容为:EmployeeID=”07”,EmployName=”张三”,Age=50。
注:连接式数据操作,采用Windows集成验证。
SqlConnection con = new SqlConnection();
con.ConnectionString = “Data Source= ; Initial Catalog = ; Integrated Security = ”;
con. ;
SqlCommand Com = new SqlCommand( );
Com.Connection = ;
Com.CommandText = ;
Com. ;

ForeignKeyConstraint c = new ForeighKeyConstraint(“Class_Stu”, ds.Tables[Classinfo].Columns[0] , ds.Tables[Stuinfo].Columns[2]);
ds.Tables[Stuinfo].Constraints.Add( );

SqlConnection con = new SqlConnection();
con.ConnectionString = “Data Source=127.0.0.1 ; Initial Catalog =Northwind ; Integrated Security = true”;
con.open() ;
SqlCommand Com = new SqlCommand( );
Com.Connection = con;
Com.CommandText = "insert into employeeinfo values(07,张三,50)";
Com.ExecuteNonQuery() ;
Com.CommandText = "select * from employeeinfo where age>40";
int x = com.ExecuteNonQuery() ;
con.close() ;
label1.Text = “统计出年龄大于40岁的员工人数为”+x.ToString( );

我也不会