在运行模式下找不到表0 [英] cannot find table 0 in running mode

查看:92
本文介绍了在运行模式下找不到表0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#网站的调试中遇到问题,无法在此代码中找到表0



I'' am getting the problem in debug in C# web site is cannot find table 0 on this code



using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using ORCMS.DAL;
using ORCMS.Entity;
public partial class Admin_ResourceRegister : System.Web.UI.Page
{
    string war, amc;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {          
            ControlBinder.BindDepartments(dpdldept);
            ControlBinder.BindEmployee(dpdlUserName);
            ControlBinder.BindResourceCategory(dpdlCategory);              
        }
    }
    protected void dpdlCategory_SelectedIndexChanged(object sender, EventArgs e)
    {
        ControlBinder.BindResourceType(dpdlType, dpdlCategory);
    }    
    protected void btnclear_Click(object sender, EventArgs e)
    {   
        txtResourceName.Text = string.Empty;
       
        dpdlCategory.SelectedItem.Value = string.Empty;
        dpdlType.SelectedItem.Value = string.Empty;
        dpdlUserName.SelectedItem.Value = string.Empty;
        txtconfig.Text = string.Empty;
        txtipadd.Text = string.Empty;
        txtUsedFor.Text = string.Empty;
        dpdldept.SelectedItem.Value = string.Empty;
        txtregdate.Text = string.Empty;
        
       
    }   
    
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        ResourceRegistration oResReg = new ResourceRegistration();
        DALResorceRegistration oDALResReg = new DALResorceRegistration();
                 
        string sError=string.Empty;
        if (rdbWarNo.Checked == true)
        {
            war = rdbWarNo.Text;
        }
        else
        {
            war = rdbWarYes.Text;
        }
        if (rdbAMCNo.Checked == true)
        {
            amc = rdbAMCNo.Text;
        }
        else
        {
            amc = rdbAMCYes.Text;
        }
                    
        try
        {
            oResReg.Config = txtconfig.Text;
            oResReg.DeptID = Convert.ToInt32(dpdldept.SelectedItem.Value);
            oResReg.IpAdd = txtipadd.Text;
            oResReg.RegDate = Convert.ToDateTime(txtregdate.Text);
            oResReg.ResType = dpdlType.SelectedItem.Value;
            oResReg.RseName = txtResourceName.Text;
            oResReg.UsedFor = txtUsedFor.Text;
            oResReg.UserID = Convert.ToInt32(dpdlUserName.SelectedItem.Value);
            oResReg.AMC = amc;
            oResReg.warranty = war;
            DataSet oDsResult = oDALResReg.InsertResourceDetails(oResReg, ref sError);
            if (oDsResult != null && oDsResult.Tables != null &&
                oDsResult.Tables[0].Rows.Count > 0 &&
                oDsResult.Tables[0].Rows[0]["RC"].ToString().Equals("0"))
            {                
                txtconfig.Text = string.Empty;
                txtipadd.Text = string.Empty;
                txtregdate.Text = string.Empty;
                txtResourceName.Text = string.Empty;
                txtUsedFor.Text = string.Empty;
                dpdlCategory.SelectedIndex = dpdldept.Items.IndexOf(
                dpdldept.Items.FindByValue("Select"));
                dpdldept.SelectedIndex = dpdldept.Items.IndexOf(
                dpdldept.Items.FindByValue("Select"));
                dpdlType.SelectedIndex = dpdldept.Items.IndexOf(
                dpdldept.Items.FindByValue("Select"));
                dpdlUserName.SelectedIndex = dpdldept.Items.IndexOf(
                dpdldept.Items.FindByValue("Select Employee Name"));
                lblServerMsg.Text = oDsResult.Tables[0].Rows[0]["ServerMsg"].ToString();
            }
            else
            {
                lblServerMsg.Text = oDsResult.Tables[0].Rows[0]["ServerMsg"].ToString();
            }
        }
        catch (Exception oEx)
        {
            lblServerMsg.Text = oEx.Message;
        }        
    }

推荐答案

C#网站在此代码上找不到表0
它仅表示运行查询时数据库不返回任何数据.

您需要调试,并在数据库层中查看是否返回了数据.检查所形成的查询是否正确且有效.运行直接在数据库上形成的原始查询,并查看是否返回任何数据.如果是这样,请查看您的处理方式以及是否使用正确的ADO.NET代码来传递数据.
C# web site is cannot find table 0 on this code
It simply means that the database does not returned any data when you ran your query.

You need to debug and see in the Database layer if the data was returned. Check for the query formed if correct and working. Run the raw query formed directly on database and see if any data is being returned. If so, see how you are handling it and if you are using correct ADO.NET code to pass on the data.


这篇关于在运行模式下找不到表0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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