public void getDatabase() { String str = "server=localhost\\SQL2005;uid=abctest;pwd=***;database=dbnametest;"; String dbname = new SQLServerDialect().GetConnectionItem( str, ConnectionItemType.Database ); Assert.AreEqual( dbname, "dbnametest" ); }
public override Object SetParameter(IDbCommand cmd, String parameterName, Object parameterValue) { parameterValue = base.processValue(parameterValue); parameterName = new SQLServerDialect().GetParameterAdder(parameterName); IDbDataParameter parameter = new SqlParameter(parameterName, parameterValue); cmd.Parameters.Add(parameter); return(parameterValue); }
public void getDatabase() { String str = "server=localhost\\SQL2005;uid=abctest;pwd=***;database=dbnametest;"; IDatabaseDialect x = new SQLServerDialect(); String dbname = x.GetConnectionItem( str, ConnectionItemType.Database ); Assert.AreEqual( dbname, "dbnametest" ); String dbserver = x.GetConnectionItem( str, ConnectionItemType.Server ); Assert.AreEqual( dbserver, "localhost\\SQL2005" ); String userId = x.GetConnectionItem( str, ConnectionItemType.UserId ); Assert.AreEqual( userId, "abctest" ); String pwd = x.GetConnectionItem( str, ConnectionItemType.Password ); Assert.AreEqual( pwd, "***" ); }
public void testExpress() { String str = "Server=.\\SQLExpress;AttachDbFilename=C:\\MyFolder\\MyDataFile.mdf;Database=dbname;Trusted_Connection=Yes;"; IDatabaseDialect x = new SQLServerDialect(); String dbname = x.GetConnectionItem( str, ConnectionItemType.Database ); Assert.AreEqual( dbname, "dbname" ); String dbserver = x.GetConnectionItem( str, ConnectionItemType.Server ); Assert.AreEqual( dbserver, ".\\SQLExpress" ); String IsTrusted = x.GetConnectionItem( str, ConnectionItemType.IsTrusted ); Assert.AreEqual( IsTrusted, "Yes" ); }
public void testTrust() { // 下面也可以 // Data Source=.;Initial Catalog=mytest;Integrated Security=True // Data Source=.;Initial Catalog=mytest;Trusted_Connection=True String str = "Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;"; IDatabaseDialect x = new SQLServerDialect(); String dbname = x.GetConnectionItem( str, ConnectionItemType.Database ); Assert.AreEqual( dbname, "myDataBase" ); String dbserver = x.GetConnectionItem( str, ConnectionItemType.Server ); Assert.AreEqual( dbserver, "myServerAddress" ); String IsTrusted = x.GetConnectionItem( str, ConnectionItemType.IsTrusted ); Assert.AreEqual( IsTrusted, "True" ); String IsTrusted2 = x.GetConnectionItem( "Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=True", ConnectionItemType.IsTrusted ); Assert.AreEqual( IsTrusted2, "True" ); }
public void testPort2() { String str = "Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;"; IDatabaseDialect x = new SQLServerDialect(); String dbname = x.GetConnectionItem( str, ConnectionItemType.Database ); Assert.AreEqual( dbname, "myDataBase" ); String dbserver = x.GetConnectionItem( str, ConnectionItemType.Server ); Assert.AreEqual( dbserver, "190.190.200.100,1433" ); String userId = x.GetConnectionItem( str, ConnectionItemType.UserId ); Assert.AreEqual( userId, "myUsername" ); String pwd = x.GetConnectionItem( str, ConnectionItemType.Password ); Assert.AreEqual( pwd, "myPassword" ); }
public void testPort() { String str = "server=192.168.1.122,1230;uid=myname;pwd=abc111;database=mydb;"; IDatabaseDialect x = new SQLServerDialect(); String dbname = x.GetConnectionItem( str, ConnectionItemType.Database ); Assert.AreEqual( dbname, "mydb" ); String dbserver = x.GetConnectionItem( str, ConnectionItemType.Server ); Assert.AreEqual( dbserver, "192.168.1.122,1230" ); String userId = x.GetConnectionItem( str, ConnectionItemType.UserId ); Assert.AreEqual( userId, "myname" ); String pwd = x.GetConnectionItem( str, ConnectionItemType.Password ); Assert.AreEqual( pwd, "abc111" ); }
public void testOther2() { String str = "Server=.;Database=myDataBase;User Id=myUsername;Password=myPassword;"; IDatabaseDialect x = new SQLServerDialect(); String dbname = x.GetConnectionItem( str, ConnectionItemType.Database ); Assert.AreEqual( dbname, "myDataBase" ); String dbserver = x.GetConnectionItem( str, ConnectionItemType.Server ); Assert.AreEqual( dbserver, "." ); String userId = x.GetConnectionItem( str, ConnectionItemType.UserId ); Assert.AreEqual( userId, "myUsername" ); String pwd = x.GetConnectionItem( str, ConnectionItemType.Password ); Assert.AreEqual( pwd, "myPassword" ); }