hi
I usually did my database in SQL Server Management Studio Express then when I was in Visual Studios I would connect to it in the server explorer tab but I wanted to try to do it through Visual studios so I took my database files then went to my app_data folder and added them as existing items. I then went back to the server explorer tab and set it up.
Everything thing seemed to set up but when I run it I get an error.
I get this error when it does conn.Open();
Error:
1System.Data.SqlClient.SqlException was unhandledbyuser code2 Message="Cannotopen database \"Japanese\" requestedby the login. The login failed.\r\nLogin failedforuser'HOWSER\\chobo'."3 Source=".Net SqlClient Data Provider"4 ErrorCode=-21462320605 Class=116 LineNumber=655367 Number=40608Procedure=""9 Server="localhost\\SqlExpress"10 State=111 StackTrace:12 at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)13 at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)14 at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)15 at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)16 at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)17 at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)18 at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)19 at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentityidentity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)20 at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)21 at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)22 at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)23 at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)24 at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)25 at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)26 at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)27 at System.Data.SqlClient.SqlConnection.Open()28 at Practice.Page_Load(Object sender, EventArgs e)in h:\Website\Japanese\Practice.aspx.cs:line 2829 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)30 at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)31 at System.Web.UI.Control.OnLoad(EventArgs e)32 at System.Web.UI.Control.LoadRecursive()33 at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)34
This is what I have as my connection stuff
webconfig
1 <connectionStrings>2 <add name="Japanese" connectionString="Server=localhost\SqlExpress;3 Database=Japanese; Integrated Security=True"4 providerName ="System.Data.SqlClient"/>5 </connectionStrings>67
In my file
1 SqlConnection conn;2 SqlCommand comm;3 SqlDataReader reader;45string connectionString = ConfigurationManager.ConnectionStrings["Japanese"].ConnectionString;6 conn =new SqlConnection(connectionString);78 comm =new SqlCommand("SELECT HiraganaCharacter,HiraganaImage FROM Hiragana", conn);9 conn.Open();10 reader = comm.ExecuteReader();Thanks
Hi,
can you check your code connection string?
it would be usually in this format for SQLserver connection in the config file:
connectionString="Data Source=yourservername;Initial Catalog=yourdatabasename;User ID=userid"providerName="System.Data.SqlClient"
Hope this helps
No comments:
Post a Comment