Error Con
Contents |
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/General ASP.NET/Configuration and Deployment/con.Open(); ERROR con.Open(); ERROR [Answered]RSS 6 replies Last post Jan 06, 2012 02:42 AM by mahajan344 ‹ con.open() error in c# Previous Thread|Next Thread › Print Share Twitter Facebook Email Shortcuts Active Threads
How To Solve Con Open Error In Asp Net
Unanswered Threads Unresolved Threads Support Options Advanced Search Reply reporter-rep... Member 2 Points 10 Posts con.Open(); ERROR Jan con.open() c# 01, 2012 06:26 PM|reporter-reporter|LINK Hi I am new to asp.net and I have been going through a few online tutorials. I found this one (http://www.aspdotnet-suresh.com/2010/10/how-to-get-output-parameters-return-by.html) and had been following it, system.componentmodel.win32exception: the system cannot find the file specified but there is a problem with the con.Open(); and it is throwing up an error when I go to view in browser. The problem happened when i changed my connection string to my own one. It didnt like laptop-PC\sqlexpress as the datasource, so I changed it to (local) which it then seemed to accept but then it said I had a con error with con.Open(); SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=mydb;Integrated Security=True"); con.Open(); Can anyone advise? Thanks Reply Dan Bracuk Participant 1882 Points 1056 Posts Re: con.Open(); ERROR Jan 01, 2012 06:35 PM|Dan Bracuk|LINK The text of error messages usually contain clues as to why the error occurred. What did yours say? Reply aspnet2sams Participant 995 Points 702 Posts Re: con.Open(); ERROR Jan 02, 2012 12:27 AM|aspnet2sams|LINK Hi, try changinglaptop-PC with the name of your laptop. For that steps are as follows: Desktop->My Computer->Right-click (context menu)->properties->Opens systemproperties dialog box->Go to Computer name Tab->here note the name given to you computer. and modify the conn string with this. Note: The steps are for Windows XP Pro. Other OS of windows it could vary. Please let the forum know. good luck. The risk in compilation of snippets from aspnet2sams is at post made by person. snippets are to show the path for getting the job done particular to thread. Reply faheemsial Member 61 Points 30 Posts Re: con.Open(); ERROR Jan 03, 2012 01:59 AM|faheemsial|LINK First of all verify your connection string
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/General http://forums.asp.net/t/1754826.aspx?con+Open+ERROR ASP.NET/Configuration and Deployment/con.Open(); ERROR/Re: con.Open(); ERROR View Complete Thread Shortcuts Active Threads Unanswered Threads Unresolved Threads Support Options Advanced Search Reply https://forums.asp.net/post/4761235.aspx jennyortem Member 110 Points 92 Posts Re: con.Open(); ERROR Jan 03, 2012 02:53 AM|jennyortem|LINK Hello, Please verify your connection string Java Software This site is managed for Microsoft by Neudesic, LLC. | © 2016 Microsoft. All rights reserved. Privacy Statement| Terms of Use| Contact Us| Advertise With Us| CMS by Umbraco| Hosted on Microsoft Azure Feedback on ASP.NET| File Bugs| Support Lifecycle
here for a quick overview of the site Help Center Detailed answers http://stackoverflow.com/questions/7254356/con-open-has-an-error-i-have-a-connection-error-an-my-code-looks-like-this to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack error in Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up con.open has an error.I have a connection error an my code looks like this up vote -4 down vote favorite if (lblevent.Text == Request.QueryString["name"]) con.open() error in { string EventName = Request.QueryString["name"]; const string SQL = "SELECT SMS FROM Event WHERE EventName = @EventName"; using (SqlConnection con = new SqlConnection(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=PSeminar;Integrated Security=true;Trusted_Connection=Yes;MultipleActiveResultSets=true")) using (SqlCommand Command = new SqlCommand(SQL, con)) Command.Parameters.Add("@EventName", EventName); { con.Open();//at here the "con" has an error it says:"'con' does not exist on current context." } } Actually i have already declared an sqlconnection(con) int he above code but it does not read it. Please someone help.. Thanks c# asp.net sql-server-2008 share|improve this question edited Aug 31 '11 at 8:30 Marek Grzenkowicz 12.5k65483 asked Aug 31 '11 at 8:22 user917145 1317 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote This is the problem: using (SqlConnection con = new SqlConnection("...")) using (SqlCommand Command = new SqlCommand(SQL, con)) Command.Parameters.Add("@EventName", EventName); { con.Open(); ... } That's equivalent to: using (SqlConnection con = new SqlConnection("...")) { using (SqlCommand Command