Questions tagged [sqlconnection]

Represents an open connection to a SQL Server database.

SqlConnection is a class in .Net's System.Data.SqlClient library that represents a connection between the local machine and a SQL Server database.

The connection can be configured using its ConnectionString property, and must be opened before use (and closed or disposed after use). ADO.NET also implements pooling for the internal connection used by SqlConnection, so calling Open is relatively cheap.

ADO.NET does not provide thread safety for SqlConnection, nor any of the objects that use it (such as SqlCommand or SqlDataReader) - these objects should be used on the same thread as the SqlConnection, and by only one thread at once.

For more information on SqlConnection, see its MSDN page: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx

1086 questions
-4
votes
1 answer

SqlConnection error index 0 in c#

In the code below i see this error when i try to connect to connection string thiss error appears Format of the initialization string does not conform to specification starting at index 0. How can i fix it? In the code below i see this error when i…
aarriiaann
  • 56
  • 8
-4
votes
1 answer

Why don't I have a definition for 'ExecuteScalar'?

I have searched for my answer only to find that there was a typo in someone's code. I have not found why this code does not have a definition for ExecuteScalar(). I might actually need to capture Customer_Id when I actually add the row to the SQL…
Dave Hampel
  • 160
  • 3
  • 13
-4
votes
3 answers

how to create an array of Sqlconnection

is it possible to create an array of SqlConnection? For expample; SqlConnection[] con = new SqlConnection[4]; con[0].ConnectionString = "my connection string"; when write this code it gives no error but when you run it it says: Object reference…
ypbr
  • 208
  • 3
  • 14
-5
votes
1 answer

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll?

I'm getting an error and I don't know why! using(SqlConnection sqlcon = new SqlConnection(con)) { sqlcon.Open(); SqlCommand cmd = new SqlCommand("dbo.workScheduleDataGrid", sqlcon); cmd = sqlcon.CreateCommand(); cmd.CommandType =…
-5
votes
1 answer

SQL Server with C#

I am writing a program that connects to a SQL Server (IGOR-PC - SQL Server 10.50.4044 - instance Igor-PC\Igor) The code is this: SqlConnection myConnection = newSqlConnection("Server=.\\Igor;Database=Prueba"); myConnection.Open(); But I get this…
yerena.jon
  • 11
  • 3
-7
votes
1 answer

Sql connection using jquery in HTML?

Is it possible to get Sql connection using jquery? If it is possible, please tell me how to get it step-by-step.
Pikachu
  • 27
  • 1
  • 6
1 2 3
72
73