插入批量数据时检查列名称 [英] Check the column names while inserting bulk data

查看:72
本文介绍了插入批量数据时检查列名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







目前我正在从Excel到SQL数据库进行批量数据插入。

我的总逻辑工作正常。但我的问题是列名应该是唯一的,现在我想检查一下。



ex:



column1:title



但是客户输入column1的值是title



在这种情况下我不想插入数据我想显示错误信息。



如何做到这一点可以帮助我解决这个问题。



在此先感谢.....

Hi,


Currently i''m doing Bulk data insert from Excel to SQL database.
My total logic is working fine for inserting. But my question is column name should be unique , now i want to check that.

for ex:

column1 : Title

but client enter the column1 value is "title"

In this case i don''t want to insert data i want to display the error message .

How to do this can any one help me to resolve this issue.

Thanks in Advance.....

推荐答案

您可以使用Regex类来获取此类值。



you can use Regex class for such values.

string originalValue="Title";
string enteredValue="title";
static bool IsValid(string orgValue, string entValue)
{
    return Regex.IsMatch(orgValue,"^" + entValue + "


); // 请记住,这将检查整个字符串
}
"); //Remember, this will check for the whole string }





如果返回false,则标记错误。



If it returns false, Flag an Error.


这篇关于插入批量数据时检查列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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