以编程方式验证数据集 [英] Dataset validation programmatically

查看:71
本文介绍了以编程方式验证数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用C#编程语言验证数据集?

how i can validate dataset in c# programming language?

推荐答案

尝试一下
http://msdn.microsoft.com/en-us/library /ms171930(v=vs.80).aspx#Y1719 [
Try this
http://msdn.microsoft.com/en-us/library/ms171930(v=vs.80).aspx#Y1719[^]


尝试此代码示例
私人void Button1_Click(System.object sender,System.EventArgs e)
{
DataSet ds = new DataSet();
字符串sqlStr;
OleDb.OleDbDataAdapter da;
sqlStr = this.TextBox1.Text.Trim();
da =新的OleDb.OleDbDataAdapter(sqlStr,this.ComposerTableAdapter.Connection);
试试
{
da.Fill(ds,"TestSQL");
this.c1List1.DataSource = null;
this.c1List1.ClearFields();
this.c1List1.DataSource = ds.Tables("TestSQL");
}
catch(Exception x)
{
MsgBox(无效的SQL语句.");
}
}
try this code sample
private void Button1_Click( System.object sender, System.EventArgs e)
{
DataSet ds = new DataSet();
string sqlStr;
OleDb.OleDbDataAdapter da;
sqlStr = this.TextBox1.Text.Trim();
da = new OleDb.OleDbDataAdapter(sqlStr, this.ComposerTableAdapter.Connection);
try
{
da.Fill(ds, "TestSQL");
this.c1List1.DataSource = null;
this.c1List1.ClearFields();
this.c1List1.DataSource = ds.Tables("TestSQL");
}
catch( Exception x)
{
MsgBox("Invalid SQL statement.");
}
}


这篇关于以编程方式验证数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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