简体   繁体   English

C#Windows应用程序:使用Windows身份验证连接到远程SQL Server 2008的连接字符串

[英]C# Windows application: connection string to connect to remote sql server 2008 using windows authentication

I am developing a windows form application using c#. 我正在使用c#开发Windows窗体应用程序。 I want to connect to SQL Server 2008 which is in the server using windows authentication. 我想使用Windows身份验证连接到服务器中的SQL Server 2008。 Can anyone please provide me the connection string? 有人可以提供连接字符串吗?

Note: 注意:

  1. Domain is created in my server. 域是在我的服务器中创建的。
  2. Remote access is enabled for the sql server 为SQL Server启用了远程访问
  3. TCP/IP port is also enabled. TCP / IP端口也已启用。

Please help me.I am struggling for this since 3 days. 请帮助我。自3天以来,我一直在为此奋斗。

Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;

如果是本地的,你可以尝试一下。它将使用默认实例。我认为这会帮助你

Data Source=.;Initial Catalog=yourDBName;Integrated Security=True

I am not clear on the issue you are facing, are u running the Application on your domain cred, and you're able to access the DB? 对于您面临的问题,我不清楚,您是否在域信誉级别上运行应用程序,并且能够访问数据库? . What is your current DB connection string template? 您当前的数据库连接字符串模板是什么? (3 days, seems like a long time for this issue, i must be missing something) (3天,这个问题似乎很长一段时间,我一定很想念东西)

Follow the below steps in your visual studio, 在Visual Studio中执行以下步骤,

  1. Go To Tools menu and click on "Connect to Database". 转到工具菜单,然后单击“连接到数据库”。
  2. If it is a first time a small window will open with below options 如果是第一次,将打开一个带有以下选项的小窗口
    • Microsoft Access Database File Microsoft Access数据库文件
    • Microsoft ODBC Data Source Microsoft ODBC数据源
    • Microsoft SQL Server Microsoft SQL服务器
    • Microsoft SQL Server Comapct 3.5 Microsoft SQL Server Comapct 3.5
    • Microsoft SQL Server Database File Microsoft SQL Server数据库文件
    • Oracle Database 甲骨文数据库
  3. In your case, click on "Microsoft SQL Server" and click Continue. 对于您的情况,请单击“ Microsoft SQL Server”,然后单击“继续”。
  4. Then a new window will prompt which takes input like -Server Name -choose your server name (First time it will take some time to load list of server name). 然后,将出现一个新窗口,提示输入-Server Name之类的内容-选择服务器名称(第一次加载服务器名称列表会花费一些时间)。 You can get your server name by opeing SQL Server. 您可以通过运行SQL Server获得服务器名称。

    • Log on to the server 登录到服务器

    option 1 - Use Windows Authentication (As this is the first time you are using, I will suggest to use this option) option 2 - use SQL Server Authentication (If your choosing this, provide your SQL Server Username and password) 选项1-使用Windows身份验证(因为这是您第一次使用,建议使用此选项)。选项2-使用SQL Server身份验证(如果选择此选项,请提供SQL Server用户名和密码)

  5. Connect to Database -Select or Enter the Database name (From the Dropdown select your database to which you want to connect) 连接到数据库-选择或输入数据库名称(从下拉列表中选择要连接的数据库)
  6. After filling above details, Click on "Advanced" button and it will take you to another pop-up window 填写完以上详细信息后,单击“高级”按钮,它将带您到另一个弹出窗口
    • In that window, just above "Ok" button there will be a non-editable column with name DataSource. 在该窗口的“确定”按钮上方,将有一个不可编辑的列,名称为DataSource。 Simply copy the text under it. 只需复制下面的文字。 This is you Connection string. 这是您的连接字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用给定的连接字符串连接到SQL Server(使用C#Windows应用程序) - Unable to connect To the SQL server using the given connection String (using C# windows Application) 无法通过Windows身份验证使用连接字符串连接到SQL Server - Unable to connect to SQL Server using a connection string with Windows authentication 在IIS中使用带有连接字符串的Windows身份验证连接到SQL 2008 R2 - Using Windows Authentication with Connection string in IIS to connect to SQL 2008 R2 C#:如何从另一台局域网计算机和Windows身份验证连接到SQL Server 2008 Express? - C#: how to connect to sql server 2008 express from another lan computer and windows authentication? 如何将Windows CE c#应用程序连接到数据库SQL Server2008r2 - How to connect windows CE c# application to database SQL Server2008r2 SQL Server 2008中的C#远程连接 - C# remote connection in sql server 2008 Windows Server 2008上的SQL连接字符串 - SQL connection string on Windows Server 2008 无法从 C# 使用 Windows 身份验证连接到 SQL Server - Cannot connect to SQL Server with Windows authentication from C# sql连接字符串Windows身份验证c#winforms(未集成) - sql connection string windows authentication c# winforms (not integrated) 为什么到SQL Server的c#连接字符串不能与Windows身份验证一起使用? - Why won't my c# connection string to a SQL server work with Windows authentication?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM