.net代码书写问题

来源:百度知道 编辑:UC知道 时间:2024/05/24 19:04:32
如下这段代码在.net代码中SqlCommand里面如何书写,谢谢!
select CourseName
from Course
where CourseID in (select CourseID
from StuCourse
where StuID='"+this.uid+"')

还有,我代用datagrid完全正常,为什么不显示数据呢,还是我把相关的语句删掉了?
我说的是如何用“和‘连接,直接写进去的话无效的啊!

SqlCommand cmd = new SqlCommand("select CourseName from Course where CourseID in (select CourseID from StuCourse where StuID=@StuID) ",con);
cmd.Parameter("@StuID",SqlDbType.BIGINT).Value=123;

select CourseName
from Course
where CourseID in (select CourseID
from StuCourse
where StuID='"+this.uid.Text+"')
你的 uid是什么控件?