VB.Net Datagridview数据源v / s SQL查询问题 [英] VB.Net Datagridview Datasource v/s SQL Query Problem

查看:71
本文介绍了VB.Net Datagridview数据源v / s SQL查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生,



我正在使用



datagridview.datasource = datatable.copy

来填充没有链接数据源的数据。




在这种情况下,为什么我无法编辑单元格?





1)查询下面不要更改VB.Net Datagridview单元格内容:



strSQL =& quot;选择Row_Number()Over(Order By A.Id)作为SN, A.Id,A.Face As [Object Name],B.Visi,B.AddNew,B.Edit,B.Del,B.Prnt,B.Reg,B。 XL,B.Txt,B.Email来自MSG_URightMaster A& quot; strSQL = strSQL& amp; & quot; Left Join MSG_URight B On A.Id = B.RightId Where B.UserId ='& quot; &放大器;放大器; flxGroup(flxGroup.Row,1)& amp; &安培; QUOT;&安培;#39; & quot;





2)我还使用了以下查询,这是完美的我可以更改任何单元格内容:



DIM strSQL作为字符串在查询下面让我们更改VB.Net Datagridview单元格内容:strSQL =& quot ;选择Row_Number()Over(Order By A.Id)As SN,A.Id,A.Face As [Object Name],& quot; strSQL = strSQL& amp; & quot;(选择B.Visi来自MSG_URight B,其中A.Id = B.RightId和B.UserId ='& quot;& amp; flxGroup(flxGroup.Row,1)& amp; & quot;')作为Visi,& quot; strSQL = strSQL& amp; & quot;(选择B.AddNew来自MSG_URight B,其中A.Id = B.RightId和B.UserId ='& quot;& amp; flxGroup(flxGroup.Row,1)& amp; & quot;')As AddNew,& quot; strSQL = strSQL& amp; & quot;(选择B.Edit来自MSG_URight B,其中A.Id = B.RightId和B.UserId ='& quot;& amp; flxGroup(flxGroup.Row,1)& amp; & quot;')如编辑,& quot; strSQL = strSQL& amp; & quot;(选择B.Del来自MSG_URight B,其中A.Id = B.RightId和B.UserId ='& quot;& amp; flxGroup(flxGroup.Row,1)& amp; & quot;')As Del,& quot; strSQL = strSQL& amp; & quot;(从MSG_URight B中选择B.Prnt,其中A.Id = B.RightId和B.UserId ='& quot;& amp; a

mp; flxGroup (flxGroup.Row,1)& amp;& quot;')As Prnt,& quot; strSQL = strSQL& amp; & quot;(选择B.Reg来自MSG_URight B,其中A.Id = B.RightId和B.UserId ='& quot;& amp; flxGroup(flxGroup.Row,1)& amp; & quot;')作为Reg,& quot; strSQL = strSQL& amp; & quot;(选择B.XL来自MSG_URight B,其中A.Id = B.RightId和B.UserId ='& quot;& amp; flxGroup(flxGroup.Row,1)& amp; & quot;')作为XL,& quot; strSQL = strSQL& amp; & quot;(选择B.Txt来自MSG_URight B,其中A.Id = B.RightId和B.UserId ='& quot;& amp; flxGroup(flxGroup.Row,1)& amp; & quot;')作为Txt,& quot; strSQL = strSQL& amp; & quot;(选择B.Email来自MSG_URight B,其中A.Id = B.RightId和B.UserId ='& quot;& amp; flxGroup(flxGroup.Row,1)& amp; & quot;')As Email& quot; strSQL = strSQL& amp; & quot;来自MSG_URightMaster A Order By A.ID& quot;





我很困惑。你能告诉我们为什么吗?





请告诉我,我之间的问题是什么以及我无法解决的问题改变单元格内容。





问候 -

Sanjeeb< / pre>

Respected Sir,

I am using

datagridview.datasource=datatable.copy
to populate data which has no linking datasource at all.


In that case, why am I unable to edit a cell ?


1) Below Query Let Not Change the VB.Net Datagridview Cell Content:

strSQL = &quot;Select Row_Number() Over (Order By A.Id) As SN, A.Id, A.Face As [Object Name],B.Visi,B.AddNew,B.Edit,B.Del,B.Prnt,B.Reg,B. XL,B.Txt,B.Email from MSG_URightMaster A &quot; strSQL = strSQL &amp; &quot;Left Join MSG_URight B On A.Id=B.RightId Where B.UserId=&#39;&quot; &amp; flxGroup(flxGroup.Row, 1) &amp; &quot;&#39; &quot;


2) I have also used below query which is perfect and I am able to change any cell content:

DIM strSQL as string Below Query Let Change the VB.Net Datagridview Cell Content: strSQL = &quot;Select Row_Number() Over (Order By A.Id) As SN, A.Id, A.Face As [Object Name], &quot; strSQL = strSQL &amp; &quot;(Select B.Visi From MSG_URight B Where A.Id=B.RightId And B.UserId=&#39;&quot; &amp; flxGroup(flxGroup.Row, 1) &amp; &quot;&#39;) As Visi, &quot; strSQL = strSQL &amp; &quot;(Select B.AddNew From MSG_URight B Where A.Id=B.RightId And B.UserId=&#39;&quot; &amp; flxGroup(flxGroup.Row, 1) &amp; &quot;&#39;) As AddNew, &quot; strSQL = strSQL &amp; &quot;(Select B.Edit From MSG_URight B Where A.Id=B.RightId And B.UserId=&#39;&quot; &amp; flxGroup(flxGroup.Row, 1) &amp; &quot;&#39;) As Edit, &quot; strSQL = strSQL &amp; &quot;(Select B.Del From MSG_URight B Where A.Id=B.RightId And B.UserId=&#39;&quot; &amp; flxGroup(flxGroup.Row, 1) &amp; &quot;&#39;) As Del, &quot; strSQL = strSQL &amp; &quot;(Select B.Prnt From MSG_URight B Where A.Id=B.RightId And B.UserId=&#39;&quot; &amp;a
mp; flxGroup(flxGroup.Row, 1) &amp; &quot;&#39;) As Prnt, &quot; strSQL = strSQL &amp; &quot;(Select B.Reg From MSG_URight B Where A.Id=B.RightId And B.UserId=&#39;&quot; &amp; flxGroup(flxGroup.Row, 1) &amp; &quot;&#39;) As Reg, &quot; strSQL = strSQL &amp; &quot;(Select B.XL From MSG_URight B Where A.Id=B.RightId And B.UserId=&#39;&quot; &amp; flxGroup(flxGroup.Row, 1) &amp; &quot;&#39;) As XL, &quot; strSQL = strSQL &amp; &quot;(Select B.Txt From MSG_URight B Where A.Id=B.RightId And B.UserId=&#39;&quot; &amp; flxGroup(flxGroup.Row, 1) &amp; &quot;&#39;) As Txt, &quot; strSQL = strSQL &amp; &quot;(Select B.Email From MSG_URight B Where A.Id=B.RightId And B.UserId=&#39;&quot; &amp; flxGroup(flxGroup.Row, 1) &amp; &quot;&#39;) As Email &quot; strSQL = strSQL &amp; &quot;From MSG_URightMaster A Order By A.ID &quot;


I am so confused. Could you please advise why?


Kindly suggest to me what&#39;s the problem between queries that I am not able to change cell content.


Regards-
Sanjeeb</pre>

推荐答案

我的问题是,为了进一步理解你的问题,你将为什么要复制表格。我的经验是绑定到一个新实例。



My question, to further understand your question, would be why are you copying the table. My experience is to just bind to a new instance.

Dim dt as New DataTable
dt = datatable

grid.Datasource = dt





这应允许读/写实例用于操作目的。



That should allow a read/write instance for manipulation purposes.


这篇关于VB.Net Datagridview数据源v / s SQL查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆