If语句的语法问题 [英] Syntax Problem with If statement
问题描述
我正在尝试编写一个简单的ASP.net/C#页面,允许用户选择一些值并根据SQL查询生成一个报告。
我有一个自我发布下拉表单,允许用户选择要生成的
报告的类型:
选择要显示的报告类型:
< form runat =" server">
< asp:DropDownList AutoPostBack =" true" ID = QUOT;报告" runat =" server">
< asp:listitem>报告类型1< / asp:listitem>
< asp:listitem>报告类型2< / asp:listitem>
< asp:listitem>报告类型3< / asp:listitem>
< asp:listitem>报告类型4< / asp:listitem>
< asp:listitem>报告类型5< / asp:listitem>
< asp:listitem>报告类型6< / asp:listitem>
< / asp:DropDownList>
< / form>
我正在尝试编写一些条件逻辑来确定哪个SQL查询<将运行
:
< script language =" c#" runat =" server">
public void Page_Load(object sender,EventArgs e){
if(report.SelectedItem.Text == null)或(报告。 SelectedItem.Text ==
" Report Type 1"){
string sql_query =" SQL QUERY";
}
//运行查询
}
< / script>
不幸的是我不断收到以下错误:编译器错误消息:
CS1002 :;预计在以下行:
if(report.SelectedItem.Text == null)或(report.SelectedItem.Text ==
"报告类型1){b / b
我确信这是我的语法问题,但我只是遇到问题
确定要使用的正确语法。有人可以提供任何指示或
参考文件吗?
先谢谢,
布拉德
>
I am trying to write a simple ASP.net/C# page which allows users to select
some values and produce a report based on a SQL query.
I have a self posting dropdown form which allows users to select the type of
report to generate:
Select the type of report to display:
<form runat="server">
<asp:DropDownList AutoPostBack="true" ID="report" runat="server">
<asp:listitem>Report Type 1</asp:listitem>
<asp:listitem>Report Type 2</asp:listitem>
<asp:listitem>Report Type 3</asp:listitem>
<asp:listitem>Report Type 4</asp:listitem>
<asp:listitem>Report Type 5</asp:listitem>
<asp:listitem>Report Type 6</asp:listitem>
</asp:DropDownList>
</form>
I am trying to write some conditional logic which determines which SQL query
will be run:
<script language="c#" runat="server">
public void Page_Load(object sender, EventArgs e) {
if (report.SelectedItem.Text == null) OR (report.SelectedItem.Text ==
"Report Type 1") {
string sql_query = "SQL QUERY";
}
// RUN THE QUERY
}
</script>
Unfortunately I keep getting the following error: Compiler Error Message:
CS1002: ; expected on the following line:
if (report.SelectedItem.Text == null) OR (report.SelectedItem.Text ==
"Report Type 1") {
I am sure this is a problem with my syntax but I''m just having problems
determining the correct syntax to use. Could anyone offer any pointers or
references to documentation?
Thanks in Advance,
Brad
推荐答案
" Brad Baker" <峰; br ** @ nospam.nospam>写在消息
新闻:uv ************** @ TK2MSFTNGP05.phx.gbl ...
"Brad Baker" <br**@nospam.nospam> wrote in message
news:uv**************@TK2MSFTNGP05.phx.gbl...
我正在写一个简单的ASP.net/C#页面,允许用户选择一些值并根据SQL查询生成报告。
我有一个自发帖子下拉表单,允许用户选择输入要生成的报告类型:
选择要显示的报告类型:
< form runat =" server">
< asp:DropDownList的AutoPostBack = QUOT;真" ID = QUOT;报告" runat =" server">
< asp:listitem>报告类型1< / asp:listitem>
< asp:listitem>报告类型2< / asp:listitem>
< asp:listitem>报告类型3< / asp:listitem>
< asp:listitem>报告类型4< / asp:listitem>
< asp:listitem>报告类型5< / asp :listitem>
< asp:listitem>报告类型6< / asp:listitem>
< / asp:DropDownList>
< / form>
我正在尝试编写一些条件逻辑来确定将运行哪个SQL
查询:
< script language =" c#" runat =" server">
public void Page_Load(object sender,EventArgs e){
if(report.SelectedItem.Text == null)OR(report.SelectedItem.Text ==
报告类型1){
string sql_query =" SQL QUERY" ;;
}
//运行查询
}
< / script>
不幸的是我不断收到以下错误:编译器错误消息:
CS1002 :;预计在以下行:
if(report.SelectedItem.Text == null)OR(report.SelectedItem.Text ==
" Report Type 1"){
我确信这是我的语法问题,但我只是遇到问题
确定要使用的正确语法。任何人都可以提供任何指示或
文件参考吗?
提前致谢,
布拉德
I am trying to write a simple ASP.net/C# page which allows users to select
some values and produce a report based on a SQL query.
I have a self posting dropdown form which allows users to select the type
of report to generate:
Select the type of report to display:
<form runat="server">
<asp:DropDownList AutoPostBack="true" ID="report" runat="server">
<asp:listitem>Report Type 1</asp:listitem>
<asp:listitem>Report Type 2</asp:listitem>
<asp:listitem>Report Type 3</asp:listitem>
<asp:listitem>Report Type 4</asp:listitem>
<asp:listitem>Report Type 5</asp:listitem>
<asp:listitem>Report Type 6</asp:listitem>
</asp:DropDownList>
</form>
I am trying to write some conditional logic which determines which SQL
query will be run:
<script language="c#" runat="server">
public void Page_Load(object sender, EventArgs e) {
if (report.SelectedItem.Text == null) OR (report.SelectedItem.Text ==
"Report Type 1") {
string sql_query = "SQL QUERY";
}
// RUN THE QUERY
}
</script>
Unfortunately I keep getting the following error: Compiler Error Message:
CS1002: ; expected on the following line:
if (report.SelectedItem.Text == null) OR (report.SelectedItem.Text ==
"Report Type 1") {
I am sure this is a problem with my syntax but I''m just having problems
determining the correct syntax to use. Could anyone offer any pointers or
references to documentation?
Thanks in Advance,
Brad
C#中没有OR。试试||相反......
if(report.SelectedItem.Text == null || report.SelectedItem.Text ==" Report
Type 1") {
HTH :)
Mythran
There is no OR in C#. Try || instead...
if (report.SelectedItem.Text == null || report.SelectedItem.Text == "Report
Type 1") {
HTH :)
Mythran
使用| |而不是OR
- 布鲁斯(sqlwork.com)
" Brad Baker" <峰; br ** @ nospam.nospam>写在消息
新闻:uv ************** @ TK2MSFTNGP05.phx.gbl ...
use || instead of OR
-- bruce (sqlwork.com)
"Brad Baker" <br**@nospam.nospam> wrote in message
news:uv**************@TK2MSFTNGP05.phx.gbl...
我正在写一个简单的ASP.net/C#页面,允许用户选择一些值并根据SQL查询生成报告。
我有一个自发帖子下拉表单,允许用户选择输入要生成的报告类型:
选择要显示的报告类型:
< form runat =" server">
< asp:DropDownList的AutoPostBack = QUOT;真" ID = QUOT;报告" runat =" server">
< asp:listitem>报告类型1< / asp:listitem>
< asp:listitem>报告类型2< / asp:listitem>
< asp:listitem>报告类型3< / asp:listitem>
< asp:listitem>报告类型4< / asp:listitem>
< asp:listitem>报告类型5< / asp :listitem>
< asp:listitem>报告类型6< / asp:listitem>
< / asp:DropDownList>
< / form>
我正在尝试编写一些条件逻辑来确定将运行哪个SQL
查询:
< script language =" c#" runat =" server">
public void Page_Load(object sender,EventArgs e){
if(report.SelectedItem.Text == null)OR(report.SelectedItem.Text ==
报告类型1){
string sql_query =" SQL QUERY" ;;
}
//运行查询
}
< / script>
不幸的是我不断收到以下错误:编译器错误消息:
CS1002 :;预计在以下行:
if(report.SelectedItem.Text == null)OR(report.SelectedItem.Text ==
" Report Type 1"){
我确信这是我的语法问题,但我只是遇到问题
确定要使用的正确语法。任何人都可以提供任何指示或
文件参考吗?
提前致谢,
Brad
I am trying to write a simple ASP.net/C# page which allows users to select
some values and produce a report based on a SQL query.
I have a self posting dropdown form which allows users to select the type
of report to generate:
Select the type of report to display:
<form runat="server">
<asp:DropDownList AutoPostBack="true" ID="report" runat="server">
<asp:listitem>Report Type 1</asp:listitem>
<asp:listitem>Report Type 2</asp:listitem>
<asp:listitem>Report Type 3</asp:listitem>
<asp:listitem>Report Type 4</asp:listitem>
<asp:listitem>Report Type 5</asp:listitem>
<asp:listitem>Report Type 6</asp:listitem>
</asp:DropDownList>
</form>
I am trying to write some conditional logic which determines which SQL
query will be run:
<script language="c#" runat="server">
public void Page_Load(object sender, EventArgs e) {
if (report.SelectedItem.Text == null) OR (report.SelectedItem.Text ==
"Report Type 1") {
string sql_query = "SQL QUERY";
}
// RUN THE QUERY
}
</script>
Unfortunately I keep getting the following error: Compiler Error Message:
CS1002: ; expected on the following line:
if (report.SelectedItem.Text == null) OR (report.SelectedItem.Text ==
"Report Type 1") {
I am sure this is a problem with my syntax but I''m just having problems
determining the correct syntax to use. Could anyone offer any pointers or
references to documentation?
Thanks in Advance,
Brad
>
嗨!
再次检查语法:
if(report.SelectedItem.Text == null)或(报告。 SelectedItem.Text ==
" Report Type 1")
此行**应该**阅读:
if((report.SelectedItem.Text == null)OR(report.SelectedItem.Text ==
" Report Type 1"))
注意附加括号...
- 杰克
-
雅各布W安德森
---
http://www.beyond-ordinary .com
http://www.accessquery.com
---
如果您认为聘请专业人员来完成这项工作很昂贵,请等待
,直到你雇用业余爱好者。
" Brad Baker"写道:
Hi!
Check your syntax again:
if (report.SelectedItem.Text == null) OR (report.SelectedItem.Text ==
"Report Type 1")
This line **SHOULD** read:
if ( (report.SelectedItem.Text == null) OR (report.SelectedItem.Text ==
"Report Type 1") )
Note the addition of the enclosing parenthesis ...
-- Jake
--
Jacob W Anderson
---
http://www.beyond-ordinary.com
http://www.accessquery.com
---
If you think it''''s expensive to hire a professional to do the job, wait
until you hire an amateur.
"Brad Baker" wrote:
我正在尝试编写一个简单的ASP.net/C#页面,允许用户选择某些值并根据SQL查询生成报告。 />
我有一个自我发布下拉表单,允许用户选择要生成的报告类型:
选择要显示的报告类型:
< ; form runat =" server">
< asp:DropDownList AutoPostBack =" true" ID = QUOT;报告" runat =" server">
< asp:listitem>报告类型1< / asp:listitem>
< asp:listitem>报告类型2< / asp:listitem>
< asp:listitem>报告类型3< / asp:listitem>
< asp:listitem>报告类型4< / asp:listitem>
< asp:listitem>报告类型5< / asp :listitem>
< asp:listitem>报告类型6< / asp:listitem>
< / asp:DropDownList>
< / form>
我正在尝试编写一些条件逻辑来确定将运行哪个SQL查询:
< script language =" c#" runat =" server">
public void Page_Load(object sender,EventArgs e){
if(report.SelectedItem.Text == null)OR(report.SelectedItem.Text ==
报告类型1){
string sql_query =" SQL QUERY" ;;
}
//运行查询
}
< / script>
不幸的是我不断收到以下错误:编译器错误消息:
CS1002 :;预计在以下行:
if(report.SelectedItem.Text == null)OR(report.SelectedItem.Text ==
" Report Type 1"){
我确信这是我的语法问题,但我只是遇到问题
确定要使用的正确语法。任何人都可以提供任何指示或
文件参考吗?
提前致谢,
Brad
I am trying to write a simple ASP.net/C# page which allows users to select
some values and produce a report based on a SQL query.
I have a self posting dropdown form which allows users to select the type of
report to generate:
Select the type of report to display:
<form runat="server">
<asp:DropDownList AutoPostBack="true" ID="report" runat="server">
<asp:listitem>Report Type 1</asp:listitem>
<asp:listitem>Report Type 2</asp:listitem>
<asp:listitem>Report Type 3</asp:listitem>
<asp:listitem>Report Type 4</asp:listitem>
<asp:listitem>Report Type 5</asp:listitem>
<asp:listitem>Report Type 6</asp:listitem>
</asp:DropDownList>
</form>
I am trying to write some conditional logic which determines which SQL query
will be run:
<script language="c#" runat="server">
public void Page_Load(object sender, EventArgs e) {
if (report.SelectedItem.Text == null) OR (report.SelectedItem.Text ==
"Report Type 1") {
string sql_query = "SQL QUERY";
}
// RUN THE QUERY
}
</script>
Unfortunately I keep getting the following error: Compiler Error Message:
CS1002: ; expected on the following line:
if (report.SelectedItem.Text == null) OR (report.SelectedItem.Text ==
"Report Type 1") {
I am sure this is a problem with my syntax but I''m just having problems
determining the correct syntax to use. Could anyone offer any pointers or
references to documentation?
Thanks in Advance,
Brad
>
这篇关于If语句的语法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!