处于窗口身份验证模式时如何与数据库连接. [英] how to connect with database when we are in window Authentication mode.

查看:49
本文介绍了处于窗口身份验证模式时如何与数据库连接.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友

当我们处于sql server的窗口验证"模式时,请告诉我如何使用c#与sql server连接.与SQL连接时,我正在编写以下代码...

Dear friends

Please tell me how to connect with sql server with c# when we are in Window Authentiation mode in sql server. while connecting with SQL i am writing following code...

SqlConnection con = new SqlConnection();
                con.ConnectionString = " Data Source = UPADHYAY-PC\\SQLEXPRESS; Initial Catalog = belwal";
                con.Open();


但其显示登录失败.因为没有用户名和密码. ...

请帮忙....

感谢


but its showing Logon fail. because there is not user id and password. ...

please help....

thanks

推荐答案

在窗口身份验证模式下的情况...
使用以下代码

in case of window authentication mode......
use following code

SqlConnection con = new SqlConnection();
con.ConnectionString = " Data Source = UPADHYAY-PC\\SQLEXPRESS; Initial Catalog = belwal; integrated Security=true;"


用于窗口身份验证模式
For window authentication mode
con.ConnectionString = " Data Source = localhost\\SQLEXPRESS; Initial Catalog = belwal; integrated Security=true;"


这篇关于处于窗口身份验证模式时如何与数据库连接.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆