sqlconnection Questions

12

Solved

An application that has been working without problem (and has not had any active development done on it in about 6 months or so) recently began failing to connect to database. Operations admins can...
Dombrowski asked 17/9, 2012 at 15:41

12

How do you check if it is open or closed I was using if (SQLOperator.SQLCONNECTION.State.Equals("Open")) however, even the State is 'Open' it fails on this check.
Curarize asked 4/8, 2011 at 15:13

8

I'm trying to write Connection string to Web.config like this: <connectionStrings> <add name="Dbconnection" connectionString="Server=localhost; Database=OnlineShopping ; Integrated Sec...
Jaynajayne asked 25/8, 2013 at 16:28

8

Solved

First question: Say I have using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); string storedProc = "GetData"; SqlCommand command = new SqlCommand(store...
Nostomania asked 17/1, 2011 at 20:55

7

This one has me stumped. I'm not even trying to connect to a database. When this code gets to the line where I instantiate a new SqlConnection object, it just hangs there, not throwing an exception...
Omar asked 6/12, 2011 at 23:10

4

I am using this sql connection string : string connection = "data source=OSBORNECHARLES2;initial catalog=TWO; integrated security=False;User ID=userid;Password=PWD"; I am getting this error : ...
Antonietta asked 4/9, 2012 at 13:54

5

SQLConnection use randomly namedpipes(445) instead of tcp(1433). The namedpipes port is blocked by our firewall but not the tcp. This only happens when trying to connect to one of our sql servers. ...
Blackboard asked 23/9, 2016 at 13:47

10

Solved

I am trying to override the default SqlConnection timeout of 15 seconds and am getting an error saying that the property or indexer cannot be assigned because it is read only. Is there a way ...
Buffybuford asked 11/4, 2012 at 14:57

7

Solved

To test if i can connect to my database, I execute the following code : using (SqlConnection connection = new SqlConnection(myConnectionString)) { try { connection.Open(); canConnect = true; ...
Majunga asked 8/4, 2010 at 16:6

9

I am creating a project in which I need to run 2-3 SQL commands in a single SQL connection. Here is the code I have written: SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;At...
Idiocy asked 3/12, 2012 at 4:51

6

Solved

Is there any difference between SqlCommand.CommandTimeout and SqlConnection.ConnectionTimeout in .NET?
Crabber asked 11/5, 2009 at 8:55

2

Solved

I am seeing constant deadlocks in my app, even though it performs no select statements, no delete statements, and no update statements. It is only inserting completely new data. TL;DR: It seems to ...

8

Solved

using (SqlConnection con = new SqlConnection()) { try { con.Open(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } This works fine. But I want to know can we handle exception w...
Valdemar asked 24/4, 2012 at 18:52

1

Solved

I am trying to inject IConfiguration (Microsoft.Extensions.Configuration package) into Program.cs and don't know if that is possible and therefore obviously don't know how to do it, if possible. I'...

4

Solved

Can I use this approach efficiently? using(SqlCommand cmd = new SqlCommand("GetSomething", new SqlConnection(Config.ConnectionString)) { cmd.Connection.Open(); // set up parameters and CommandTy...
Statius asked 13/9, 2008 at 22:10

3

Solved

This is the connection string saved in web.config: <appSettings> <add key="conn" value="Driver={MySQL ODBC 5.1 Driver};server=127.0.0.1;uid=root;pwd=1234;database=gis_server;option=3"/&g...
La asked 15/8, 2013 at 12:58

2

Solved

I have simple WPF client application (.NET 4.6.2) with one button. SqlConnection.OpenAsync method blocks the UI thread when following steps are done: SQL Server is started and reachable from clie...
Clodhopping asked 3/8, 2019 at 9:48

4

Solved

I found this piece of code in one application Database database = DatabaseFactory.CreateDatabase("connection string"); DbConnection connection = database.CreateConnection(); connection.Open(); Sql...
Canicula asked 5/9, 2010 at 19:40

3

Solved

I feel silly for even having to ask this, but I must be missing something. I am simply trying to open a new SqlConnection to my LocalDB instance on my development machine. Visual Studio 2013. I...
Seidule asked 8/12, 2014 at 20:24

6

Solved

I usually use code like this: using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString)) { var command = connection.CreateCommand(); command.Co...
Goshen asked 27/11, 2009 at 10:47

2

Solved

When I try to do the following code, the program hangs indefinitely. I don't know why and there seems to be other unanswered topics on the matter. Although, if the IP\website cannot be reached, the...

6

Solved

I have my business-logic implemented in simple static classes with static methods. Each of these methods opens/closes SQL connection when called: public static void DoSomething() { using (SqlConne...
Muggy asked 14/12, 2010 at 12:59

1

Solved

I have a SqlConnection object accessible to my code. All other ADO.NET objects like SqlCommand, SqlParameter etc are not accessible to me. These other objects are consumed by Dapper Extensions ORM....
Devan asked 26/5, 2017 at 6:10

1

I'm facing really strange issue. Given the code below: static void Main() { var c = new System.Data.SqlClient.SqlConnection(); c.ConnectionString = "Data Source=SOME_NAME;Initial Catalog=SOME_D...
Boucicault asked 4/5, 2018 at 14:49

7

I getting below error on trying to connect with the database : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or ...
Karb asked 30/3, 2018 at 7:32

© 2022 - 2024 — McMap. All rights reserved.