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
-1
votes
1 answer

Connection to server with sqlconnection not working

Can anyone help me with that? I am trying to connet but it didnt work. Imports System.Data.SqlClient Public Class Form2 Public Property newForm As Object Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click …
-1
votes
1 answer

System.ArgumentException: Keyword not supported: 'password'

My code has a database connection health monitor mechanism which checks the database connection state and if the connection is broken, it tries to reconnect after every 30 seconds. During the retries, it uses a SqlConnection object and assigns a…
nauman73
  • 1
  • 3
-1
votes
4 answers

C# database connection SQL

I'm trying to make it so I can use the program where ever I put the folder so it's not just restricted to be in one specific place. This is the connection string i'm using right now string constring = "Data Source =…
-1
votes
1 answer

How to convert sqlDataReader to Task async

I have the following code-can anyone please tell me if I can make this a async Task public MDTO GetIe(MDTO dtoItem) { string[] Tables = new string[] { "C", "CValue", "SP", "Ar", "P", "CR", "QC", "SR" }; using (SqlConnection…
klkj898
  • 31
  • 5
-1
votes
1 answer

Max. no. of connections that SQLite database can provide

What is the maximum no. of connections that SQLite database can provide? I'm using SQLite database with Java for the development of small desktop application. After few successful connection I got error message like this: SQLite database file is…
user5880962
-1
votes
3 answers

StackOverflowException sqlConnection.Open() at publish only

I made a web proyect, and in all the preview codes compiling (F5) i was abble to test and continue using my programs and codes, after I finished it... i need to publish my web app, y have 4 Main classes, Bussines,Data,Entity and Visual, after this i…
-1
votes
1 answer

ASP.net C# The ConnectionString property has not been initialized

I have a gridview that has a Edit button. when user click on that button, the contents of the gridview (that shows tbl_userContents table) goes to some textboxes, then he can change the contents and click on save button. when he clicks the save…
sana
  • 3
  • 5
-1
votes
1 answer

Make SQL Server database read only except for one stored procedure

I have a stored procedure which migrate data from this database to another. To exclude any error, I want to make the database read only for every transaction except mine. I use SqlConnection and SqlCommand to run the script. Is there any way to do…
Kiss László
  • 265
  • 4
  • 16
-1
votes
1 answer

Using Variables in SQL Query Run Through Code

I want to pass a variable to a sql string being executed via C#. I am hitting a compile error tho, and I am not perfectly sure how to end my sql statement with my variable. This is the line of code that I have string Fire =…
Big Pimpin
  • 427
  • 9
  • 23
-1
votes
1 answer

SQL SELECT protocol in C#

I've tried searching StackOverflow but the query returns a lot of unrelated results and I did spend time looking elsewhere before posting. I am writing an app in C# / ASP.NET and would like to pull just the Full Names and id from the database of…
Dan Beaulieu
  • 19,406
  • 19
  • 101
  • 135
-1
votes
1 answer

Trouble establishing connection to Local SQL database

Simply trying to find out the correct syntax for my connection string. Before anyone asks, yes I did look at other SO answers, and no they did not work for me. Here a couple of attempts I made from looking at other SO questions like the one I am…
Jordan M
  • 1
  • 2
  • 13
-1
votes
1 answer

how to insert data from database in combox

I'm trying to insert data from my database in a combo box specifically showing all my tables in the combobox here's my connection private void Form1_Load(object sender, EventArgs e) { string connetionString = null; SqlConnection cnn; …
Amped
  • 1
  • 1
-1
votes
2 answers

should use using/end using or manually close sqlConnection

in the following methods which is the suitable to work with SQL Method 1 Using conn As New SqlConnection("....") conn.Open() '/to do End Using Method 2 Try dim conn as new sqlconnection =("....") conn.open() '/to do Catch …
friend
  • 41
  • 1
  • 2
  • 6
-1
votes
2 answers

Creating dataSource in Java according to c# code

I need to create dataSource in Java and I know that connection to this data base in C# looks like this: SqlConnection connection = new SqlConnection("Data Source=exampleds;Initial Catalog=exampleic;Integrated Security=True"); I want to understand,…
Skeeve
  • 1,205
  • 3
  • 16
  • 31
-1
votes
2 answers

Insert into the database "MDF" does not work

Honestly I've tried everything and in many ways, but I can not give a simple INSERT in the database. Please could someone tell me what is wrong with this code? using (SqlConnection con = new SqlConnection(AcessoBD.ConnectionString)) { string…
Ronald Araújo
  • 1,395
  • 4
  • 19
  • 30