Click here to Skip to main content
15,916,293 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: how to connect database to asp.net form Pin
Member 127613417-Jul-17 18:58
Member 127613417-Jul-17 18:58 
Brother this is error showing in this way "Line no. 22 con.open();

Server Error in '/' Application.

Database 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\LoginDB1.mdf' already exists. Choose a different database name.
Cannot attach the file 'C:\Users\Atta\Documents\Visual Studio 2012\WebSites\WebSite3\App_Data\aspnet-WebSite3-20170707151050.mdf' as database 'LoginDB1'.

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: Database 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\LoginDB1.mdf' already exists. Choose a different database name.
Cannot attach the file 'C:\Users\Atta\Documents\Visual Studio 2012\WebSites\WebSite3\App_Data\aspnet-WebSite3-20170707151050.mdf' as database 'LoginDB1'.

Source Error: 


Line 20:     {
Line 21:         SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connect"].ToString());
Line 22:         con.Open();
Line 23:         string query = "select count(*) from userlogin where username ='" + txtBox1.Text + "'and pass '" + txtBox2.Text + "'";
Line 24:         SqlCommand cmd = new SqlCommand(query, con);

Source File: c:\Users\Atta\Documents\Visual Studio 2012\WebSites\WebSite3\Default2.aspx.cs    Line: 22 

Stack Trace: 


[SqlException (0x80131904): Database 'C:\Program Files (x86)\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\LoginDB1.mdf' already exists. Choose a different database name.
Cannot attach the file 'C:\Users\Atta\Documents\Visual Studio 2012\WebSites\WebSite3\App_Data\aspnet-WebSite3-20170707151050.mdf' as database 'LoginDB1'.]
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling) +821
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +332
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +699
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +89
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +426
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
   System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +191
   System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +154
   System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +21
   System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +90
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +217
   System.Data.SqlClient.SqlConnection.Open() +96
   Default2.Button1_Click(Object sender, EventArgs e) in c:\Users\Atta\Documents\Visual Studio 2012\WebSites\WebSite3\Default2.aspx.cs:22
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9819334
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +204
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1639

GeneralRe: how to connect database to asp.net form Pin
Richard Deeming10-Jul-17 2:36
mveRichard Deeming10-Jul-17 2:36 
QuestionXML based News page in ASP.NET MVC Pin
Alberto Bencivenni7-Jul-17 2:18
Alberto Bencivenni7-Jul-17 2:18 
AnswerRe: XML based News page in ASP.NET MVC Pin
Richard Deeming7-Jul-17 2:59
mveRichard Deeming7-Jul-17 2:59 
GeneralRe: XML based News page in ASP.NET MVC Pin
Alberto Bencivenni7-Jul-17 3:04
Alberto Bencivenni7-Jul-17 3:04 
QuestionReflect changes by not having to clear cookies or refresh pages on production after upgrade Pin
Schatak5-Jul-17 22:45
professionalSchatak5-Jul-17 22:45 
AnswerRe: Reflect changes by not having to clear cookies or refresh pages on production after upgrade Pin
F-ES Sitecore6-Jul-17 0:26
professionalF-ES Sitecore6-Jul-17 0:26 
GeneralRe: Reflect changes by not having to clear cookies or refresh pages on production after upgrade Pin
Schatak7-Jul-17 1:31
professionalSchatak7-Jul-17 1:31 
GeneralRe: Reflect changes by not having to clear cookies or refresh pages on production after upgrade Pin
F-ES Sitecore7-Jul-17 2:40
professionalF-ES Sitecore7-Jul-17 2:40 
GeneralRe: Reflect changes by not having to clear cookies or refresh pages on production after upgrade Pin
Schatak11-Jul-17 19:05
professionalSchatak11-Jul-17 19:05 
AnswerRe: Reflect changes by not having to clear cookies or refresh pages on production after upgrade Pin
Richard Deeming6-Jul-17 1:41
mveRichard Deeming6-Jul-17 1:41 
GeneralRe: Reflect changes by not having to clear cookies or refresh pages on production after upgrade Pin
Schatak24-Jul-17 20:25
professionalSchatak24-Jul-17 20:25 
GeneralRe: Reflect changes by not having to clear cookies or refresh pages on production after upgrade Pin
Richard Deeming25-Jul-17 0:31
mveRichard Deeming25-Jul-17 0:31 
QuestionMicrosoft.AspNet.FriendlyUrls Pin
Member 110895115-Jul-17 22:37
Member 110895115-Jul-17 22:37 
AnswerRe: Microsoft.AspNet.FriendlyUrls Pin
Richard Deeming6-Jul-17 1:38
mveRichard Deeming6-Jul-17 1:38 
QuestionHow to associate a role with action from my custom UI Pin
Mou_kol4-Jul-17 4:04
Mou_kol4-Jul-17 4:04 
AnswerRe: How to associate a role with action from my custom UI Pin
F-ES Sitecore4-Jul-17 4:17
professionalF-ES Sitecore4-Jul-17 4:17 
QuestionLDAP Group List for Windows User Pin
Dirk Bahle3-Jul-17 9:56
Dirk Bahle3-Jul-17 9:56 
AnswerRe: LDAP Group List for Windows User Pin
F-ES Sitecore3-Jul-17 23:15
professionalF-ES Sitecore3-Jul-17 23:15 
QuestionGet the query string with parameteres ( parameter value can be change) Pin
Member 44632353-Jul-17 1:35
Member 44632353-Jul-17 1:35 
AnswerRe: Get the query string with parameteres ( parameter value can be change) Pin
Richard Deeming3-Jul-17 1:51
mveRichard Deeming3-Jul-17 1:51 
QuestionMVC Application RoleManager issue after being deployed in Azure Pin
Farhad Eft29-Jun-17 4:54
Farhad Eft29-Jun-17 4:54 
AnswerRe: MVC Application RoleManager issue after being deployed in Azure Pin
F-ES Sitecore29-Jun-17 23:41
professionalF-ES Sitecore29-Jun-17 23:41 
Suggestionproject definition Pin
Member 1327996126-Jun-17 17:59
Member 1327996126-Jun-17 17:59 
GeneralRe: project definition Pin
Richard MacCutchan26-Jun-17 20:56
mveRichard MacCutchan26-Jun-17 20:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.