捕捉到 System.Data.SqlClient.SqlException Message=对象名 '' 无效
建立的Connecting的链接,数据是指向A。
我现在通过A的数据库链接要向B数据库中写入数据(A和B是在同一台服务器上。)
代码如下
MasterCmd = new SqlCommand("select * from B..p_material where tParentId=101", db.thisSqlconnection);
MasterAdapter = new SqlDataAdapter();
MasterAdapter.SelectCommand = MasterCmd;
MasterDt = new DataTable();
MasterAdapter.Fill(MasterDt);
上面代码是打开B数据库中p_material,是可以读取数据的
DR = MasterDt.NewRow();
......
MasterDt.Rows.Add(DR);
MasterAdapter.Update(MasterDt);
上面的代码在向B数据库中p_material插入数据时报错提示:
捕捉到 System.Data.SqlClient.SqlException Message=对象名 'p_material' 无效。
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060 Class=16 LineNumber=1 Number=208
Procedure=""
Server=10.97.138.145
State=1
StackTrace:
在 System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
在 System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
在 System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
在 System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
在 System.Data.Common.DbDataAdapter.Update(DataTable dataTable)
在 HCSZ_EMC.Film_Frm_P_Material.AddNew() 位置 C:\Users\00100146\Desktop\HCSZ_EMC\HCSZ_EMC\HCSZ_EMC\Film_Frm_P_Material.cs:行号 265
在 HCSZ_EMC.Film_Frm_P_Material.tbtSave_Click(Object sender, EventArgs e) 位置 C:\Users\00100146\Desktop\HCSZ_EMC\HCSZ_EMC\HCSZ_EMC\Film_Frm_P_Material.cs:行号 298
InnerException:
求教大神们如何解决。
(要是能新建B数据库的链接,就不存在此问题了。)