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

Login field for user 'root' ...Localhost Mysql

im trying to store som data into mysql database on localhos but i got this message: Login field for user 'root im sure about the uid and pws are right. private void button1_Click_1(object sender, EventArgs e) { String connection =…
user2269364
  • 67
  • 1
  • 9
-1
votes
3 answers

SqlConnection() exception

i am having following trouble with this code. unhandled exception of type 'System.ArgumentException' occurred in System.Data.Dll static void Main(string[] args) { SqlConnection con = new SqlConnection(); con.ConnectionString =…
samEE666
  • 3
  • 6
-1
votes
1 answer

sqlconnection error during installation in C#

i created a software,which worked fine in Visual Studio. but when i deploy it on any computer it gives the following error while trying to make connection to the database:- ************** Exception Text…
user2257581
  • 87
  • 1
  • 1
  • 9
-2
votes
1 answer

C# SQL connection parameters login

I'm still a beginner, I'm going to do some "inserts", I want 'Server, data, User, Pass" information to input "textbox" for the SQL used. for me to insert accordingly. how can I connect the link chain "texbox" below? Source=" + Server.Text + " it…
Advett
  • 17
-2
votes
1 answer

Removing the Hardcoded MySQL connection string

This is the connection string that connect the C++ code with the MySQL and this is hardcoded so if some other user have to run the solution they have to change the username servername Pwd. My question is how do I remove this hard code so that it…
-2
votes
1 answer

How can I fix this error in my C# and T-SQL code

I fill a data table with a SQL query and I get this error: System.Data.SqlClient.SqlException: 'Incorrect syntax near '='. Here is my code: SqlConnection sqlConnection = new SqlConnection("Data Source=OWNER;Initial…
-2
votes
1 answer

How to connect this project with sql

executenonquery() error c# this is how my code looks like con.Open(); String name = textBox1.Text.ToString(); String address = textBox2.Text.ToString(); String id = textBox3.Text.ToString(); int iid = Int32.Parse(id); String semester =…
Hatemii
  • 39
  • 3
-2
votes
1 answer

Must declare the scalar variable "@GenName"

I am getting this error when trying to run the code below. Any insight on to what I am doing wrong? I am pretty new to this, and want to get this to work pretty bad. I have gotten zero help from this site so far in a previous question I asked. But…
Mr.B
  • 1
  • 6
-2
votes
1 answer

C# SQL Check box to be ticked when data present

I am slowing learning my way round c# and SQL. I have started a project that will have a list of checkboxes. I want these checkboxes to be ticked if there is any data present within the table. I am not interested in what data, only if there is data…
Chris Birch
  • 41
  • 2
  • 7
-2
votes
1 answer

Connection String Is not Working Object instance reference is null

//'Object reference not set to an instance of an object.' Please Do not mark it as redundant question . I have tried almost all the methods to make a connection string first one is by : string connectionString =…
Mark Dibeh
  • 469
  • 7
  • 21
-2
votes
1 answer

How can I get informations from my database in c# (without SqlConnection-Class)

Hello Stackoverflow Community,Im new in C# and databanks and I have the following problem: I am writing a windows forms application, one of the forms is a logon-screen where the user can type his name into a text field. I want to check if the name…
Antoine
  • 21
  • 8
-2
votes
1 answer

references error when trying "using" and "SqlConnection" initialization line

I'm new to C# and may be using this all wrong. but this is the part of my code that I'm having problems with. using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Text; using…
AnotherBrick
  • 153
  • 3
  • 6
  • 14
-2
votes
1 answer

"ping" from C# to SQL Server

i need ur help .I need to develop a function in Application WPF , that will be fired each 30 seconds, to ping to server and check if it's not connect to sql server, we will display Error message .Is there a way to simply "ping" from C# SQL…
S.Snoy
  • 39
  • 8
-2
votes
1 answer

SqlConnection and SqlCommand with using statement

I have a connection to a database set up like this to call a stored procedure. I am just wondering if this is the best way to do this. I have two using statements one for the sqlConnection and one for the sqlCommand (which I am not really sure if…
psj01
  • 3,075
  • 6
  • 32
  • 63
-2
votes
2 answers

Error Trying To Fill Data Table

This is my syntax, but I get an error of The SelectCommand property has not been initialized before calling 'Fill'. what do I need to do in order to be able to fill the data table? using (SqlConnection conn = new…