数据源配置向导错误。需要帮助 [英] Data source configuration wizard error. Help needed

查看:122
本文介绍了数据源配置向导错误。需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试从我的访问(2016)中插入数据库对象到我的C#(2015)时,当我点击完成后我收到连续错误...



处理数据库对象时发生一个或多个错误

< newuser>

无法检索表或视图NewUser的架构信息。'





这是我目前的代码...

有人能帮我这个吗?



 OleDbConnection connection =  new  OleDbConnection( @  Provider = Microsoft.ACE.OLEDB.12.0; Data Source = | DataDirectory | \DatabaseEmployees.accdb; Persist Security Info = True); 
OleDbCommand command = new OleDbCommand();

int i = 0 ;
if (IDtbx.Text == string .Empty)
{
MessageBox.Show( 请登录);
}
command = new OleDbCommand( 从NewUser中选择count(*),其中Username =' + IDtbx.Text + ' AND Password =' + PSWtbx.Text + ',connection);

if (connection.State == ConnectionState.Closed)
{
connection.Open();
i =( int )command.ExecuteScalar();
}

connection.Close();
if (i > 0
{
MainSystem mainForm = new MainSystem();
mainForm.FormClosed + = new FormClosedEventHandler(Login_FormClosed);
mainForm.Show();
this .Hide();
LoginError.Visible = false ;
}

else
{
LoginError.Visible = ;
}

}





我尝试过:



我尝试使用链接到C#的所有其他三个数据库,删除数据库并重新开始

解决方案

< blockquote>不是你的问题的解决方案,但你有另一个问题。

永远不要通过连接字符串来构建SQL查询。迟早,您将使用用户输入来执行此操作,这会打开一个名为SQL注入的漏洞,这对您的数据库很容易并且容易出错。

名称中的单引号你的程序崩溃。如果用户输入像Brian O'Conner这样的名称可能会使您的应用程序崩溃,那么这是一个SQL注入漏洞,崩溃是最少的问题,恶意用户输入,并且它被提升为具有所有凭据的SQL命令。

SQL注入 - 维基百科 [ ^ ]

SQL注入 [ ^ ]

按示例进行SQL注入攻击 [ ^ ]

PHP:SQL注入 - 手册 [ ^ ]

SQL注入预防备忘单 - OWASP [ ^ ]

When trying to insert database objects from my access(2016) to my C#(2015), I am getting a continuous error when I click finish of ...

one or more errors occurred while processing the database objects
<newuser>
Could not retrieve schema information for table or view NewUser.'


This is my current code...
Is anyone able to help me with this?

OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\DatabaseEmployees.accdb;Persist Security Info=True");
OleDbCommand command = new OleDbCommand();

int i = 0;
if (IDtbx.Text == string.Empty)
{
MessageBox.Show("Please log in");
}
command = new OleDbCommand("select count(*)from NewUser where Username= '" + IDtbx.Text + "' AND Password= '" + PSWtbx.Text + "'", connection);

if (connection.State == ConnectionState.Closed)
{
connection.Open();
i = (int)command.ExecuteScalar();
}

connection.Close();
if (i > 0)
{
MainSystem mainForm = new MainSystem();
mainForm.FormClosed += new FormClosedEventHandler(Login_FormClosed);
mainForm.Show();
this.Hide();
LoginError.Visible = false;
}

else
{
LoginError.Visible = true;
}

}



What I have tried:

I have tried using all three of my other databases linked to C#, deleting the database and starting again

解决方案

Not a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
SQL Injection Prevention Cheat Sheet - OWASP[^]


这篇关于数据源配置向导错误。需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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