但在执行时,它只显示:IsColumnSetSystem.Boolean
这是代码:
private voID button1_Click(object sender,EventArgs e) { string EF = textBox1.Text; try{ //sqlDataAdapter adapter = SetupDataAdapter("SELECT * FROM ID_declarant"); sqlCommand comm = new sqlCommand(); string connectionString = @"Data Source=.\sqlEXPRESS;Initial Catalog=declaration;Integrated Security=True"; comm.Connection=new sqlConnection(connectionString); String sql = @"SELECT * FROM ID_declarant,declarant WHERE (declarant.Nom_pren_RS='" + EF + "') and (ID_declarant.mat_fisc=declarant.mat_fisc) "; comm.CommandText = sql; comm.Connection.open(); sqlDataReader reader = comm.ExecuteReader(); Datatable schematable = reader.GetSchematable(); foreach (DaTarow row in schematable.Rows) { foreach (DataColumn column in schematable.Columns) { System.IO.file.WriteallText(@"C:\Users\Manuela\documents\GL4\Writelines.txt",column.Columnname + column.DataType ); } }解决方法 您正在打印由GetSchematable返回的数据表的列名,而不是其值,我建议使用StringBuilder并在退出循环时写入所有内容
StringBuilder sb = new StringBuilder(); foreach (DaTarow row in schematable.Rows) { foreach (DataColumn column in schematable.Columns) { sb.Appendline(column.Columnname + ":" +row[column.Columnname].ToString()); } sb.Appendline(); } file.WriteallText(@"C:\Users\Manuela\documents\GL4\Writelines.txt",sb.ToString());总结
以上是内存溢出为你收集整理的c# – 我们如何从getschemaTable获取Column Size和dataType?全部内容,希望文章能够帮你解决c# – 我们如何从getschemaTable获取Column Size和dataType?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)