.A_ID和.A_ID具有冲突的属性:DataType属性不匹配。 [英] .A_ID and .A_ID have conflicting properties: DataType property mismatch.
本文介绍了.A_ID和.A_ID具有冲突的属性:DataType属性不匹配。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hai先生,
我的代码是
< span class =code-keyword> protected void Page_Load( object sender,EventArgs e )
{
ReportDocument rptDoc = new ReportDocument();
DataSet2 ds = new DataSet2(); // .xsd文件名
DataTable dt = new DataTable();
// 只需设置数据表的名称
dt .TableName = Crystal Report Example;
dt = getAllOrders(); // 此函数位于此函数下方
ds.Tables [ 0 跨度>]合并(DT);
// 您的.rpt文件路径将低于
rptDoc.Load(Server.MapPath( ../ Trial / CrystalReports3.rpt));
// 将数据集设置为报告查看器。
rptDoc .SetDataSource(DS);
CrystalReportViewer1.ReportSource = rptDoc;
}
public DataTable getAllOrders()
{
// 连接字符串将'databaseservername'替换为您的数据库服务器名称
SqlCommand cmd = new SqlCommand();
DataSet ds = null ;
SqlDataAdapter适配器;
尝试
{
conn1.Open();
// 存储过程调用。它已经在示例数据库中。
cmd.CommandText = getAllOrders ;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = conn1;
ds = new DataSet();
adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds, Users);
}
catch (例外情况)
{
throw new 例外(ex.Message);
}
最后
{
cmd.Dispose();
if (conn1.State!= ConnectionState.Closed)
conn1.Close();
}
return ds.Tables [ 0 ];
}
当我执行此代码时,我收到错误
< target> .A_ID和< source /> .A_ID具有冲突的属性:DataType属性不匹配。
in ds.Tables [0] .Merge(dt );这一行。
给出一个解决方案,PLZ帮助
解决方案
查看错误描述看起来像字段数据数据类型不相同。但是看ds.Tables [0]是空的。我猜你可能要在合并之前定义这个Table [0]的列。
尝试像此以及所有列。
ds.Tables [ 0 ]。Columns.Add( Dosage, typeof ( int ));
ds.Tables [ 0 ] .. Columns.Add( 药物, typeof ( string ));
尝试这个,它对我有用......
ds.Tables [0] .Merge(dt,True,MissingSchemaAction.Ignore) ;
错误 - target-columnname-and-source-columnname-have-conflicting-properties [ ^ ]
让我知道它是否有用..
hai sir,
my code is
protected void Page_Load(object sender, EventArgs e)
{
ReportDocument rptDoc = new ReportDocument();
DataSet2 ds = new DataSet2(); // .xsd file name
DataTable dt = new DataTable();
// Just set the name of data table
dt.TableName = "Crystal Report Example";
dt = getAllOrders(); //This function is located below this function
ds.Tables[0].Merge(dt);
// Your .rpt file path will be below
rptDoc.Load(Server.MapPath("../Trial/CrystalReports3.rpt"));
//set dataset to the report viewer.
rptDoc.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rptDoc;
}
public DataTable getAllOrders()
{
//Connection string replace 'databaseservername' with your db server name
SqlCommand cmd = new SqlCommand();
DataSet ds = null;
SqlDataAdapter adapter;
try
{
conn1.Open();
//Stored procedure calling. It is already in sample db.
cmd.CommandText = "getAllOrders";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = conn1;
ds = new DataSet();
adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds, "Users");
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
cmd.Dispose();
if (conn1.State != ConnectionState.Closed)
conn1.Close();
}
return ds.Tables[0];
}
when i execute this code ,i get the error
<target>.A_ID and <source />.A_ID have conflicting properties: DataType property mismatch.
in ds.Tables[0].Merge(dt); this line.
give a solution ,plz help
解决方案
Looking at the error description it looks like the fields data datatypes are not same. But looking ds.Tables[0] is empty. My guess you might have to define the columns to this Table[0] before doing the merge.
Try like this and all your columns. ds.Tables[0].Columns.Add("Dosage", typeof(int)); ds.Tables[0]..Columns.Add("Drug", typeof(string));
Try this one, it worked for me...
ds.Tables[0].Merge(dt,True, MissingSchemaAction.Ignore);
error-target-columnname-and-source-columnname-have-conflicting-properties[^]
Let me know it is helpful or not..
这篇关于.A_ID和.A_ID具有冲突的属性:DataType属性不匹配。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文