用com1=select c,d,e from xxxx查询数据表xxxx中的c,d,e字段,然后将查询结果显示到DataGridView(VB.net)中,显示顺序为c,d,e
然后我修改com1=select a,b,c,d,e from xxxx,但是DataGridView显示的顺序是c,d,e,a,b
请问怎样把顺序调整为a,b,c,d,e?另外
com1=select a as str from xxxx,其中str为一个字符串,如果str是以数字开头,比如"10厘米高度",就会出现语法错误?
然后我修改com1=select a,b,c,d,e from xxxx,但是DataGridView显示的顺序是c,d,e,a,b
请问怎样把顺序调整为a,b,c,d,e?另外
com1=select a as str from xxxx,其中str为一个字符串,如果str是以数字开头,比如"10厘米高度",就会出现语法错误?
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" onrowcancelingedit="GridView1_RowCancelingEdit"
onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating"
onrowdeleting="GridView1_RowDeleting"
onselectedindexchanging="GridView1_SelectedIndexChanging" >
<Columns>
<asp:TemplateField HeaderText="ID">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("id") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Score">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("score") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("score") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowSelectButton="True" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
Bind 后面是字段名,你可以自己决定先绑哪个字段。2、如果str是以数字开头,比如"10厘米高度",就会出现语法错误?com1=select a as 10厘米高度 from xxxx --报错
com1=select a as '10厘米高度' from xxxx --这样应该就可以了
排序问题:
order by charindex('a,b,c,d,e',col)
字段顺序问题:
在select 中调整
数字前缀字段名/别名问题:
字段名/别名加上''或[]
如:select 'SQL' as [1a],'SQL' as '1a'
-----------
1a 1a
---- ----
SQL SQL
-----------