无法访问数据库 [英] Not able to access the Database

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

问题描述

我有与之相关的数据库和网页上传到服务器但无法从服务器访问数据库但是当通过VS2010在本地机器上运行时我能够访问它。

问到服务器管理员关于这个问题,但是他们说服务器端的一切都很好,他们说的代码有问题。



我得到以下错误:



'/'应用程序中的服务器错误。

无效的对象名称'Login'。

描述:发生了未处理的异常在执行当前Web请求期间。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。



异常详细信息:System.Data.SqlClient.SqlException:无效的对象名称'登录'。



来源错误:





第20行:SqlCommand com = new SqlCommand(从登录中选择密码,其中Username ='+ Uname_txt.Text.Trim()+',con);

第21行:con.Open();

第22行:SqlDataReader dr = com.ExecuteReader();

第23行:尝试

第24行:{

I have database and webpages related to it are uploaded on server but not able to access the database from server but when run on local machine through VS2010 i was able to access it.
Asked Server Admin also about the problem but they told that everything is fine from server side there is problem in code they are saying.

The following error i'm getting:

Server Error in '/' Application.
Invalid object name 'Login'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'Login'.

Source Error:


Line 20: SqlCommand com = new SqlCommand("select Password from Login where Username='" + Uname_txt.Text.Trim() + "'", con);
Line 21: con.Open();
Line 22: SqlDataReader dr = com.ExecuteReader();
Line 23: try
Line 24: {

推荐答案

无效的对象名称'登录'。

您尝试从登录表中执行select语句(从登录),但是从错误中可以清楚地看到你的数据库中没有这样的表(视图?)...检查它!
Invalid object name 'Login'.
You try to execute a select statement from the table 'Login' (select Password from Login), but from the error it is clear that no such table (view?) exists in your DB...Check it!


这篇关于无法访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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