开发者

SqlConnectionStringBuilder - String was not recognized as a valid Boolean

I am attempting to pass in a connection string to an SqlConnectionStringBuilder object, but I get the error: "String was not recognized as a valid Boolean", at runtime.

Here is the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace SQLClientProj
{
  class Program
  {
    static void Main(string[] args)
    {
      string cstr = @"Data Source=(local)\SQLEXPRESS;Integrated Security=IIPS;Initial Catalog=Autos";

      SqlConnectionStringBuilder cbuilder = new SqlConnectionStringBuilder(cstr);

      ...

As far as I know, cstr 开发者_StackOverflow社区is a string, so why SqlConnectionStringBuilder is complaining about expecting a boolean when it doesn't have a constructor which accepts such a type is beyond my understanding.

Any ideas?


Integrated Security=IIPS 

needs to be

Integrated Security=true

'IIPS' is not a boolean (true/false)

In a nutshell, the connection string is made up of property-value pairs,and the "Integrated Security" property specified in your string is expected to be true or false.

Look down at the "Integrated Security" section on this page:

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx


The token you are looking for is SSPI, not IIPS[sic]. Then, of course, you could, as others said, simply use true (or false).


Just a hunch, but should

Integrated Security=IIPS

be

Integrated Security=True
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜