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,010 points
451 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,420 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,060 points
1,007 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,010 points
601 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,010 points
544 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,010 points
525 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,010 points
2,778 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,010 points
236 views
0 votes
1 answer

How to convert Ods file to Data Set C#

You can see the answer here: Refer: stackoverflow.com/que ...READ MORE

answered Oct 8, 2022 in Others by narikkadan
• 63,420 points
1,102 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,420 points
1,578 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,420 points
593 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