本文介绍了在创建文件时无法将从数据库中提取的值用作变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<!-/*样式定义*/p.MsoNormal,li.MsoNormal,div.MsoNormal {mso-style-parent:";边距:0cm;底边距:.0001pt; mso分页:寡妇孤儿;字体大小:12.0pt; mso-bidi-font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} @page Section1 {size:612.0pt 792.0pt;保证金:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;}->我编写了一个网页,该网页连接到数据库,然后使用该数据库显示来自管理报告系统的3个值.

我正在使用以下代码访问数据库:

< asp:SqlDataSource ID =" SqlToVersion" runat =服务器"
ConnectionString ="<%$ ConnectionStrings:WebImportOnServer%>"
SelectCommand ="从[atblVersion]中选择[VerNo],[PeriodName],[PeriodNo]"
onselecting ="SqlToVersion_Selecting"</asp:SqlDataSource>
< asp:DetailsView ID ="DetView" runat =服务器" DataSourceID ="SqlToVersion";
Height ="50px" onpageindexchanging ="DetView_PageIndexChanging2";
Width ="273px" AutoGenerateRows =" False">
< Fields>
< asp:BoundField DataField =" VerNo" HeaderText =电子表格版本号"; ReadOnly ="True" />
< asp:BoundField DataField =" PeriodName" HeaderText =报告期间" ReadOnly ="True"
SortExpression ="PeriodName"; />
< asp:BoundField DataField =" PeriodNo" HeaderText =期间号"; ReadOnly ="True"
SortExpression ="PeriodNo" />
</Fields>
</asp:DetailsView>

这是完美的方法,但是我需要采用3个数据字段中显示的值(VerNo,

我的变量是以这种方式定义的:
Dim vcPeriodNo As Integer = ????

,但是这是如何用有效的代码替换问号的方法,该代码从我坚持使用的绑定字段中获取值.任何人都可以提供任何建议,我知道它应该很简单,但是我遇到了一个完整的问题.

<!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; mso-bidi-font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> I have written a web page which connects to a database and then display 3 values from a management reporting system using the database.

I am accessing a database using the following code:

<asp:SqlDataSource ID="SqlToVersion" runat="server"
ConnectionString="<%$ ConnectionStrings:WebImportOnServer %>"
SelectCommand="SELECT [VerNo], [PeriodName], [PeriodNo] FROM [atblVersion]"
onselecting="SqlToVersion_Selecting"></asp:SqlDataSource>
<asp:DetailsView ID="DetView" runat="server" DataSourceID="SqlToVersion"
Height="50px" onpageindexchanging="DetView_PageIndexChanging2"
Width="273px" AutoGenerateRows="False">
<Fields>
<asp:BoundField DataField="VerNo" HeaderText="Spreadsheet Version Number" ReadOnly="True" />
<asp:BoundField DataField="PeriodName" HeaderText="Reporting Period" ReadOnly="True"
SortExpression="PeriodName" />
<asp:BoundField DataField="PeriodNo" HeaderText="Period Number" ReadOnly="True"
SortExpression="PeriodNo" />
</Fields>
</asp:DetailsView>

This works perfectly, but I need to take the values displayed in the 3 datafields (VerNo , PeriodName PeriodNo ) and use them as variables in a file that is being generated from the web page.

My variables are defined in this manner:
Dim vcPeriodNo As Integer = ????

but it is how to replace the question marks with valid code that  takes the values from the bound fields that I am stuck with. Can anyone offer any advice, I know it should be simple but I have hit a complete block.

推荐答案


这篇关于在创建文件时无法将从数据库中提取的值用作变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 11:28