How can I set an SQL Server connection string

0 votes
I'm creating a straightforward C# programme, and I need to know: I am familiar with the connection string (server name, password, etc.) when I connect my programme to SQL Server on my PC, but it is different when I connect it to another PC. Is there a default account that can connect that is a common account in SQL Server?

The SQL Server sa account is something I've heard about. Describe sa.
Sep 18, 2022 in Database by Kithuzzz
• 38,000 points
701 views

1 answer to this question.

0 votes

.NET DataProvider -- Standard Connection with username and password

using System.Data.SqlClient;

SqlConnection conn = new SqlConnection();
conn.ConnectionString =
  "Data Source=ServerName;" +
  "Initial Catalog=DataBaseName;" +
  "User id=UserName;" +
  "Password=Secret;";
conn.Open();

.NET DataProvider -- Trusted Connection

SqlConnection conn = new SqlConnection();
conn.ConnectionString =
  "Data Source=ServerName;" +
  "Initial Catalog=DataBaseName;" +
  "Integrated Security=SSPI;";
conn.Open();

Refer to the documentation.

answered Sep 19, 2022 by narikkadan
• 63,600 points

Related Questions In Database

0 votes
1 answer

How Can I use "Date" Datatype in sql server?

There's problem in all of them and ...READ MORE

answered Feb 9, 2022 in Database by Neha
• 9,020 points
1,370 views
0 votes
0 answers

How can I show the table structure in SQL Server query?

Query: SELECT DateTime, Skill, Name, TimeZone, ID, User, ...READ MORE

Aug 11, 2022 in Database by Kithuzzz
• 38,000 points
806 views
0 votes
0 answers

How can I set a custom date time format in Oracle SQL Developer?

Date values are shown in Oracle SQL ...READ MORE

Aug 12, 2022 in Database by Kithuzzz
• 38,000 points
844 views
0 votes
0 answers

What represents a double in sql server?

I have several properties in C# which ...READ MORE

Aug 13, 2022 in Database by Kithuzzz
• 38,000 points
765 views
0 votes
0 answers

Error converting data type nvarchar to datetime SQL Server

I encountered this error: Error converting data type ...READ MORE

Aug 15, 2022 in Database by Kithuzzz
• 38,000 points
3,501 views
0 votes
0 answers

How to get the connection String from a database

I want to use the database I ...READ MORE

Aug 20, 2022 in Database by Kithuzzz
• 38,000 points
486 views
0 votes
1 answer

How to convert Ods file to Data Set C#

You can see the answer here: READ MORE

answered Oct 8, 2022 in Others by narikkadan
• 63,600 points
1,840 views
0 votes
1 answer

How can I import an Excel file into SQL Server?

You can use OPENROWSET to import an Excel file ...READ MORE

answered Sep 15, 2022 in Database by narikkadan
• 63,600 points
2,059 views
0 votes
1 answer

How can I create a unique constraint on my column (SQL Server 2008 R2)?

The "indexes and keys" dialogue, not the ...READ MORE

answered Sep 20, 2022 in Database by narikkadan
• 63,600 points
935 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP