sqlconnection

What is the difference between SqlCommand.CommandTimeout and SqlConnection.ConnectionTimeout?

Is there any difference between SqlCommand.CommandTimeout and SqlConnection.ConnectionTimeout in .NET? ...

When should I open and close a connection to SQL Server

I have a simple static class with a few methods in it. Each of those methods open a SqlConnection, query the database and close the connection. This way, I am sure that I always close the connection to the database, but on the other hand, I don't like to always open and close connection. Below is an example of what my methods look like. ...

Windows Authentication Trusted Connection Problem?

MSSQL Server is in the "abc" domain and have mixed mode authentication. I am connecting from the machine which is not in domain or in a domain "xyz" but with in the same network using MSSQL Jdbc driver 2.0. I have logged in as admin or account in xyz domain. It works fine using following url for connection for "sa" or SQL Mode Authentic...

Login Problem Windows Authentication

Duplicate of: http://stackoverflow.com/questions/881928/windows-authentication-trusted-connection-problem I logged in the Windows Server(Machine 1) as "abc\user1 ". Windows Server machine is in abc domain. MSSQL Server is in the "abc" domain on Machine 1 and have mixed mode.authentication. It has account "abc\user1 " and "abc\user2 ". ...

SqlConnection - is remote or local connection?

How can I determine is it local connection (localhost or 127.0.0.1) or is it remote connection (other machine in local area) if I have SqlConnection object? ...

Refactor code into using statement

I have a dal layer with lots of methods, all of them call stored procedures, some return lists (so with a use of SqlDataReader), others only a specific value. I have a helper method that creates the SqlCommand: protected SqlCommand CreateSprocCommand(string name, bool includeReturn, SqlDbType returnType) { SqlConnectio...

Managing SQL Server Connections

What is the the best practice for sql connections. Currently i am using the following: using(SqlConnection sqlConn = new SqlConnection(CONNECTIONSTRING)) { sqlConn.Open(); //DB CODE GOES HERE } I have read that this is a very effective way of doing sql connections. By default the sql pooling in active so how i understand it is tha...

Using C#'s 'using' statement with a custom object's function, do I Need to implement IDisposable?

I have an sqlConnection manager class like so: public class SQLConn { public string connStr = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]; private SqlConnection sqlConn; public SqlConnection Connection() { sqlConn = new SqlConnection(connStr); return sqlConn; } public void Open(...

Connection to SQL is not closing after call to DB in ASP.NET

I have a generic method to call a stored Procedure in ASP.NET: public SqlDataReader ExecuteStoredProc(string sprocName, SqlParameter[] SqlP) { SqlDataReader iReader; SqlCommand sql = new SqlCommand(); sql.CommandText = sprocName; sql.CommandType = CommandType.StoredProcedure; ...

In Classic ASP, are there major performance consequences of having several connections open and close?

I have a code snippet similar to the one below that I would like to refactor into two different functions each with their own connection (for better maintenance): Dim Conn, Sql, RS Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open ConnString Sql = SELECT * FROM CLIENTS Set RS = Conn.Execute(sql) //'Do something with Cl...

SqlCommand C# Issue

The below piece of code that throws the following exception.. Error Message: Object reference not set to an instance of an object. Stack Trace: at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteNonQ...

Protecting connection string from Man in the middle

In my winforms application i am hashing the connection string in local level. But here a couple of questions. After my app decrypts the connection string, the connection string info is sent in clear text? And since my app is installed locally the man in the middle could be ANY user? How can i protect the connection string, becides th...

Optimizing SQL connection performance?

This is not a question about optimizing a SQL command. I'm wondering what ways there are to ensure that a SQL connection is kept open and ready to handle a command as efficiently as possible. What I'm seeing right now is I can execute a SQL command and that command will take ~1s, additional executions will take ~300ms. This is after t...

How to set binary data using setBlob() in C++ connector

I know this has been asked before, and I tried to implement the solution, but I just get exception errors when I call ps->executeUpdate(). Has anyone got an explicit example? ...

Disposing SqlConnection from a base DAL class when calling ExecuteReader

I've been assigned on a project where the DAL consists of a base class with functions to return IDataReader, an Object (int, string and the like), or a DataSet. An ExecuteNonQuery function also exists. This DAL only accesses USPs (SQL Server), and is using MS's SqlHelper to execute the queries. Here's two sample functions from the base: ...

Do I have to Close() a SQLConnection before it gets disposed?

Per my other question here about Disposable objects, should we call Close() before the end of a using block? using (SqlConnection connection = new SqlConnection()) using (SqlCommand command = new SqlCommand()) { command.CommandText = "INSERT INTO YourMom (Amount) VALUES (1)"; command.CommandType = System.Data.CommandType.Text; ...

connecting to mySQL

One of the ERP applications I worked with was configured in such a way that there was only 1 user (for example USER A) who connected to the database. Any user of the application (workforce was in the thousands) who logged on to the system and tried to do anything was in effect calling USER A to connect to the database and execute queries...

ASP.NET ASPNETDB.MDF Cannot open database

hello, I am using membership class for my user management, and it created a database called ASPNETDB.MDF.. I decided to use the same database to handle my other data, and so I added some of my own tables in there... When I try to access it: <connectionStrings> <add name="connString" connectionString="Initial Catalog=MyProject...

How bad is opening and closing a SQL connection for several times? What is the exact effect?

For example, I need to fill lots of DataTables with SQLDataAdapter's Fill() method: DataAdapter1.Fill(DataTable1); DataAdapter2.Fill(DataTable2); DataAdapter3.Fill(DataTable3); DataAdapter4.Fill(DataTable4); DataAdapter5.Fill(DataTable5); .... .... Even all the dataadapter objects use the same SQLConnection, each Fill method will open...

Cannot connect to the sql server .

i am having management stdio 2005 in my machine and im tring to connect to sql server 2008 i'm receiving the following message as the inner exception . {"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is ...