无法打开数据库"E_learning"登录要求.登录失败. [英] Cannot open database "E_learning" requested by the login. The login failed.

查看:135
本文介绍了无法打开数据库"E_learning"登录要求.登录失败.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个应用程序,该应用程序需要一个文件并将其保存到数据库中.
这是代码

I have created an application that takes a file and saves it into database.
Here is the code

int len = FileUpload1.PostedFile.ContentLength;
byte[] pic = new byte[len];
FileUpload1.PostedFile.InputStream.Read(pic, 0, len);
cnn.Open();
cmd = new SqlCommand("insert into images values='" + pic + "'", cnn);
cmd.ExecuteNonQuery();


但是当我点击上传时,它给了我以下错误
Cannot open database "E_learning" requested by the login. The login failed.

我知道这是因为我没有在数据库连接字符串中使用uidpwd选项.其实我在SQL Server中使用Windows身份验证模式.尽管我已经创建了一个用户,但没有通过sql身份验证模式登录的用户,但是它不起作用.
有人可以帮助解决我的问题吗?


but when I click on upload it gives me the following error
Cannot open database "E_learning" requested by the login. The login failed.

I know it is because I have not used the uid and pwd options in database connection string. Actually I am using the windows authentication mode in sql server. There is no user created for the login through sql authentication mode, although I have created one, but it doesnt work.
Can anybody help to solve my problem?

推荐答案

看起来您的连接字符串不正确,它的格式必须为
Looks your connection string is not right and it will have to be in the format of
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;



请参考 http://www.connectionstrings.com/sql-server-2005 [



Please refer http://www.connectionstrings.com/sql-server-2005[^] for further information.

Also, its worth checking whether you are able to open the SQL server in the windows authentication mode.


这篇关于无法打开数据库"E_learning"登录要求.登录失败.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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