SQL两个表连接查询 - .NET技术 / C#
两个表:
产品类型表 tnclass :ID,name
产品表 tbproduct :ID,title,classid(classid就是表tbclass的那个ID),author,src
现在要根据一个产品的 id 显示这个产品的所有信息
产品标题,产品类型,产品发布人,产品图片
但我的结果显示产品类型的是id号1、2、3、4,其它的没问题,求助各位帮我改一下,谢谢了
我用的是 microsoft visual studio2005 c# 数据库是 SQL Server 2005
后台代码:
protected void Page_Load(object sender, EventArgs e)
{
string id = Request["id"];
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=.\\SQLEXPRESS;Integrated Security=True;Connect Timeout=30;User Instance=True;AttachDbFilename=" + Server.MapPath("\\XM_WebSites\\App_Data\\product.mdf");
conn.Open();
SqlCommand cmd = new SqlCommand("select * from tbproduct where id='" + id + "'",conn);
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
DataSet ds = new DataSet();
sda.Fill(ds, "tbproduct");
PagedDataSource pds = new PagedDataSource();
pds.AllowPaging = true;
pds.CurrentPageIndex = 0;
pds.PageSize = 1;
pds.DataSource = ds.Tables["tbprod
相关问答:
txt 和XML 格式相应
不借助DataSet
导入读取TXT文件
然后直接写入XML(同一文件,不同数据,递增原数据没有被覆盖情况下增加数据.)
教个要点或最好是有个代码提示的
过路好汉 帮个忙撒^^
不会,帮楼主 ......
从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
<folder state="unchecked&qu ......
现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......
我觉得mysql和sqlserver有共同的地方:
有个问题是关于表的锁问题:
进程A 进程B
select * from user where id in lock share mode(共享锁)
&nb ......
公司开发一个触摸屏程序,我负责的一块,实现这样一个功能,当鼠标点击窗口中图片(一张图分成几部分)的其中一部分时,将这部分图片截取出来,弹出新的窗口,将截取出的图片显示出来。我使用Rectange类控制了返回, ......