我的主页上有一个gridview,其中包含一个视图和一个编辑链接,它们使用查询字符串分别在只读和可编辑页面中显示表数据.我没有收到来自我的代码的错误消息,它很简单,似乎没有遗漏任何东西,但当我尝试在浏览器中调试或查看时,我在状态栏上获得永久风车并且消息"等待localhost ".我错过了什么?有没有人对这个特殊问题有一些经验?我在使用sql server 2008的可视工作室中使用C#和ASP.NET.
我正在使用Sql Server 2008在Visual Studio2010中构建一个带有产品实例表的数据库,我需要自动增加ProductId列,但是我在列属性菜单中找不到该属性.我正在使用c#和asp.net,如果这是相关的.我已经看到了创建表的代码并将列设置为自动增量,但由于这是我的第一个编码循环,我不知道在哪里放置代码.我知道创建一个新表的唯一方法是通过VS gui,如果这是有道理的.
我正在从datareader运行if else语句来查询表数据并激活/取消激活页面上的某些控件.当我关闭块时,我实现了一个using语句来自动关闭连接和读取器,但是我的每个if else语句仍然会让读者关闭错误.少了什么东西?代码如下:
string comnt = "SELECT StatusId FROM Submission WHERE SubmissionId =" + x;
using (SqlConnection editConn = new SqlConnection(connectionString))
{
editConn.Open();
using (SqlCommand statCmd = new SqlCommand(comnt, editConn))
{
SqlDataReader dr = statCmd.ExecuteReader();
dr.Read();
if (dr.GetInt32(0) > 0)
{
PanelComment.Visible = true;
PanelQuote.Visible = false;
LnbFid.Visible = false;
LnbCrim.Visible = false;
LnbEo.Visible = false;
LnbEpl.Visible = false;
LnbNot.Visible = false;
LnbPriv.Visible = false;
LnbPub.Visible = false;
}
else
{
PanelComment.Visible = false;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用asp.net和c#,制作一个带有ajax updatepanels的页面.当我尝试插入触发器元素时,我收到错误消息AsyncPostBackTrigger不是已知元素.我错过了什么?
<asp:UpdatePanel ID="UdpEPL" runat="server" UpdateMode="Conditional"
Visible="False">
<ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="BtnEplShowSubmit"
EventName="BtnEplShowSubmit_Click"/>
</Triggers>
</ContentTemplate>
</asp:UpdatePanel>
Run Code Online (Sandbox Code Playgroud) 我在vs2010中使用c#,并且学习oop; 我第一次尝试在appCode文件夹中声明对象提交时不断给出错误消息
this member defined more than once
ambiguity between Submission.SubmissionId and Submission.SubmissionId
Run Code Online (Sandbox Code Playgroud)
此错误抛出每个变量(CustId,BroId,Coverage).我按照我在语法教程中找到的模型; 这是问题吗?代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class Submission
{
int SubmissionId;
int CustId;
int BroId;
int Coverage;
//Array Product[] products;
public Submission() {}
public int SubmissionId
{
get { return SubmissionId; }
set { SubmissionId = value; }
}
public int CustId
{
get { return CustId; }
set { CustId = value; }
}
public int BroId
{
get { return …Run Code Online (Sandbox Code Playgroud) 所以我使用javascript在asp.net中用c#codebehind打开一个弹出窗口,我需要弹出窗口上的buttonclick事件来关闭弹出窗口并刷新父页面.有这个方法吗?
我是一个新手,正如我的问题所证明的那样,我正在使用datareader来查找与某个subId值相关联的行.我使用了一个while(dr.read)循环并在每种情况下与其他读者嵌套了一个switch case语句(下面的代码),但我抛出了异常"已经是一个与此命令关联的开放数据读取器,必须首先关闭它".有没有办法将第一个datareader的结果(subId = x的相关行)存储在数组或列表中,然后在我输入switch语句之前关闭该读取器?(我理解数组是什么程度,我想它会起作用,但我不知道语法会是什么样子).
string viewQuery = "SELECT ProductId FROM SubmissionProducts WHERE SubmissionId =" + x;
using (SqlCommand viewcmd = new SqlCommand(viewQuery, editConn))
{
SqlDataReader dr = viewcmd.ExecuteReader();
while (dr.Read())
{
switch(dr.GetInt32(0))
{
case 1:
PanelEplShow.Visible = true;
using (SqlCommand eplviewcmd = new SqlCommand(epl, editConn))
{
SqlDataReader epldr = eplviewcmd.ExecuteReader();
epldr.Read();
LblEplShowEntity.Text = epldr.GetString(0);
LblEplShowTotalEmpl.Text = epldr.GetInt32(1).ToString();
LblEplShowCalEmpl.Text = epldr.GetInt32(2).ToString();
LblEplShowMichEmpl.Text = epldr.GetInt32(3).ToString();
LblEplShowNyEmpl.Text = epldr.GetInt32(4).ToString();
LblEplShowNjEmpl.Text = epldr.GetInt32(5).ToString();
LblEplShowPrimEx.Text = epldr.GetInt32(6).ToString();
LblEplShowLim.Text = epldr.GetInt32(7).ToString();
LblEplShowPrem.Text = epldr.GetInt32(8).ToString();
LblEplShowWage.Text = …Run Code Online (Sandbox Code Playgroud) 我正在运行DbDataReader查询以从下拉列表中删除项目,如果它们已经附加到特定提交,并且我一直收到错误,告诉我读者已关闭.无法理解为什么我的读者被视为关闭在这里.我错过了什么?
protected void Page_Load(object sender, EventArgs e)
{
string x = Request.QueryString["SubId"];
string connectionString = System.Configuration.ConfigurationManager.
ConnectionStrings["MyConnectionString"].ConnectionString;
string displayQuery = "SELECT CustName, CustAdd, CustCity, CustState, " +
"CustZip FROM Customer WHERE SubId =" + x;
string broQuery = "SELECT EntityType FROM Broker WHERE SubId =" + x;
string ddlQuery = "SELECT ProductId FROM SubmissionProducts " +
"WHERE SubmissionId =" + x;
using (SqlConnection displayConn = new SqlConnection(connectionString))
{
displayConn.Open();
SqlCommand DlistCmd = new SqlCommand(ddlQuery, displayConn);
using (SqlDataReader Ddldr …Run Code Online (Sandbox Code Playgroud) 我在这里是个新手,可能是因为我从昨天早上起就开始了,但是我在这个插入语句中找不到我的错误.我的处理程序让我不要为这个培训项目进行参数化(它不会被部署),所以不用担心注入漏洞.无论如何,查询是正确的,数据类型是正确的,并且表和字段名称拼写正确.我在这里错过了什么?有没有更好的方法来找到它,而不仅仅是盯着屏幕,直到它来到你身边?
protected void BtnSubmit_Click(object sender, EventArgs e)
{
string x = Request.QueryString["SubId"];
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
string comQuery = "INSERT INTO Submission (Status, StatusComment, StatusValue) VALUES ('" + "decline" + "', '" + TbComments.Text + "', 2) WHERE SubmissionId =" + x;
using (SqlConnection sqlConn = new SqlConnection(connectionString))
{
sqlConn.Open();
using (SqlCommand comCmd = new SqlCommand(comQuery, sqlConn))
{
comCmd.ExecuteNonQuery();
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在迈出第一步,这需要我的应用程序,并将其全部重新设计为3层和面向对象.叹了口气.我有一个提交对象,它应该包含一个客户对象(以及一个代理和覆盖对象); 我想在每个包含的对象的字段中存储来自db的一些datareader结果,但是当我尝试使用新的提交对象调用Customer对象时,我什么也得不到.VS无法识别Submission包含Customer对象.我显然错过了一些关键点,所以考虑到这一点,想法?代码如下.
//This is the Submission class here
public class Submission
{
public int SubmissionId {get;set;}
public int Status { get; set; }
public string StatusComment { get; set; }
public class Customer
{
//public Customer() { }
public int CustId { get; set; }
public string CustName { get; set; }
public string CustAddress { get; set; }
public string CustState { get; set; }
public string CustCity { get; set; }
public int CustZip { get; …Run Code Online (Sandbox Code Playgroud) 我有一些产品,任何,全部,或者没有一个可能与特定提交相关联.所有7个产品都是产品类的子类.我需要存储与提交相关联的所有产品,然后在我的表示层上检索它们和它们的字段数据.我一直在使用List<Product>,并且List<object>,但是当我使用OfType<EPL(specific subclass)>,我抛出一个错误,说我不能隐式转换systems.generic.IEnumerable<EPL>键入"产品".我试过演员,但无济于事.
当我使用prodlist.OfType<EPL>();时没有错误,但当我尝试将其存储在EPL"tempEpl"的实例中时,我得到上述与投射相关的错误.是什么赋予了?代码如下.
ProductService pserv = new ProductService();
IList<object> prodlist = pserv.getProductById(x);
EPL tempEpl = new EPL();
if ((prodlist.OfType<EPL>()) != null)
{
tempEpl = prodlist.OfType<EPL>(); // this throws a conversion error.
}
Run Code Online (Sandbox Code Playgroud)
数据层
List<object> TempProdList = new List<object>();
conn.Open();
SqlCommand EplCmd = new SqlCommand(EPLQuery, conn);
SqlDataReader EplRead = null;
EplRead = EplCmd.ExecuteReader();
EPL TempEpl = new EPL();
if (EplRead.Read())
{
TempEpl.Entity1 = EplRead.GetString(0);
TempEpl.Employees1 = EplRead.GetInt32(1);
TempEpl.CA1 = EplRead.GetInt32(2);
TempEpl.MI1 …Run Code Online (Sandbox Code Playgroud) c# ×11
visual-studio ×10
asp.net ×9
sql-server ×7
ado.net ×1
ajax ×1
datareader ×1
html ×1
javascript ×1
oop ×1