如何在C#中通过Windows模式连接mssql2005 [英] how connect mssql2005 by windows mode in c#

查看:121
本文介绍了如何在C#中通过Windows模式连接mssql2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<b><pre lang="xml">
<?xml version="1.0" encoding="utf-8" ?>

<configuration>
  <configSections>
  </configSections>
  <connectionStrings>
    <Data Source="TISATASNIM-PC\SQLEXPRESS;Initial" Catalog="ImageViewer;Integrated" Security="True"/>

  </connectionStrings>
    <!--   User application and configured property settings go here.-->
    <!--   Example: <add key="settingName" value="settingValue"/> -->
  <!--Data Source="TISATASNIM-PC\SQLEXPRESS;Initial" Catalog="ImageViewer;Integrated" Security="True"/-->



  <system.net>
    <mailSettings>
      <smtp deliveryMethod="PickupDirectoryFromIis">
        <network defaultCredentials="true" host="localhost" port="587"/>
      </smtp>
    </mailSettings>
  </system.net>
</configuration></pre></b>
Getting error in Data Sourch.



错误:连接字符串属性未初始化...



Error: The connection string property is not initialize...

推荐答案

您需要以正确的位置和正确的格式添加连接字符串.

我会直接给你答案.阅读以下链接,您将学习如何做.

http://msdn.microsoft.com/en-us/library/ms254494 (v = vs.80).aspx [ http://www.connectionstrings.com/Articles/Show/store-connection- string-in-web-config [ ^ ]
http://www.connectionstrings.com/sql-server-2005 [
You need to add connection string in correct place and correct format.

I''m mot going to give you answer directly. read below links and you can learn how you can do it.

http://msdn.microsoft.com/en-us/library/ms254494(v=vs.80).aspx[^]
http://www.connectionstrings.com/Articles/Show/store-connection-string-in-web-config[^]
http://www.connectionstrings.com/sql-server-2005[^]


您可以按以下方式编写连接字符串:

You can write connection string in following manner :

 <add name="connection" connectionstring="Data Source=TISATASNIM-PC\SQLEXPRESS;Initial Catalog=ImageViewer;Integrated Security=True">
providerName = "System.Data.SqlClient"/>   
</add>


首先检查您的连接字符串
插入的
First Check You Connection String
Insted of
<data source="TISATASNIM-PC\SQLEXPRESS;Initial" catalog="ImageViewer;Integrated" security="True" />
 <data source="TISATASNIM-PC\SQLEXPRESS;Initial Catalog=ImageViewer;Integrated Security=True" />


像这样写连接字符串


Write Connection string like this

<add name="con1" connectionstring="Data Source=IICSS20\PMIS;Initial Catalog=PMA170711;Integrated Security=True <br mode=" hold=" />        providerName=" system.data.sqlclient=" /><br mode=" con="].ConnectionString);</xml>"></add>


后面的IN代码:

像这样加载连接字符串:


IN Code Behind:

Load Connection string like this:

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);


这篇关于如何在C#中通过Windows模式连接mssql2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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