如何解析无效的对象名;表名“;在C#中?
当我在VisualStudio2008中运行我的应用程序时,它会向我显示一个带有无效对象名“Table Name”符号的消息框,而该表已经存在于我的数据库中。所以请帮我解决这个问题如何解析无效的对象名;表名“;在C#中?,c#,sql-server,C#,Sql Server,当我在VisualStudio2008中运行我的应用程序时,它会向我显示一个带有无效对象名“Table Name”符号的消息框,而该表已经存在于我的数据库中。所以请帮我解决这个问题 private void FrmInwardDisp2_Load(object sender, EventArgs e) { byte _true = 1; byte _false = 0; //this.toolTip1.SetToolTip(this.dgvDisplay, "Double Click
private void FrmInwardDisp2_Load(object sender, EventArgs e)
{
byte _true = 1;
byte _false = 0;
//this.toolTip1.SetToolTip(this.dgvDisplay, "Double Click to Edit");
int width = Screen.PrimaryScreen.Bounds.Width;
int height = Screen.PrimaryScreen.Bounds.Height - 175;
dgvDisplay.Width = width - 25;
dgvDisplay.Height = height;
//dgvDisplay.AutoSize = true;
try
{
SqlConnection con = new SqlConnection(Variables.con);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.SelectCommand = cmd;
switch (Static_Class.selected)
{
case 1:
{
btnAddInward.Text = "Add Rental Inward";
cmd.CommandText = "SELECT [RentalInwardNo],[VoucherNo],[NameOfWork]
[Location],[NameOfVendor],[VendorCode],[VendorItemCode],[ItemName],
[Narration],[WareHouse],[DriverName],[VehicleNo],[RejectedItemCode],
[RejectedItemName],[Rate],[Date],[InvoiceNo],[ChallanNo],[TenderCode],
[PINo],[PONo],[UnitQty],[UOM],[RequisitionNo],[ReceivedBy],
[LocationID],[Layer],[Local],[Global],[DeleteStatus],[AutoGenerated]
FROM IN_Rental_Inward
where [TenderCode]= " + Static_Class.tendercode + "
and [LocationID]='" + Static_Class.LocationID + "'
and [Layer]='" + Static_Class.Layer + "'
and [DeleteStatus]=" + 0;
try
{
//con.Open();
da.Fill(ds, "TableDisplay");
da.Dispose();
cmd.Dispose();
//con.Close();
dgvDisplay.DataSource = ds.Tables["TableDisplay"];
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
break;
在查询文本中,在表名之前指定表的架构名。例如:
cmd.CommandText = "SELECT … FROM dbo.IN_Rental_Inward …";
// ^^^^
欢迎来到StackOverflow。请阅读和。你也可以坐飞机。完成此操作后,请正确编辑您的问题。您能显示一些代码吗?发布一些代码以便我们提供帮助:)我将您的标题复制到Google并找到以下堆栈溢出答案:我尝试了此链接,但在我的代码中不起作用我尝试了schema.table name,但它不起作用