本文整理汇总了C#中Db.IsConnected方法的典型用法代码示例。如果您正苦于以下问题:C# Db.IsConnected方法的具体用法?C# Db.IsConnected怎么用?C# Db.IsConnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Db
的用法示例。
在下文中一共展示了Db.IsConnected方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestIfValidConnectionString
public void TestIfValidConnectionString()
{
var db = new Db();
db.Connect();
Assert.AreEqual(db.IsConnected(), true);
db.CloseConn();
Assert.AreEqual(db.IsConnected(), false);
}
示例2: TestIfInvalidConnectionString
public void TestIfInvalidConnectionString()
{
var db = new Db();
db.ConString = "Server=localhosts;Database=testdb;Uid=root;Pwd=;";//erroneous
db.Connect();
Assert.AreEqual(db.IsConnected(), false);
}
示例3: TestIfSingleCellValueIsSelected
public void TestIfSingleCellValueIsSelected()
{
var db = new Db();
db.Connect();
if (db.IsConnected())
{
db.Connect();
db.bind("id", "1");
string p = db.single("select age from persons where id = @id");
Assert.AreEqual(p, "19");
db.CloseConn();
}
}
示例4: TestIfRowValuesAreSelected
public void TestIfRowValuesAreSelected()
{
var db = new Db();
db.Connect();
if (db.IsConnected())
{
db.bind("id", "1");
string[] p = db.row("select * from persons where id = @id");
Assert.AreEqual(p[0], "1");
Assert.AreEqual(p[1], "John");
Assert.AreEqual(p[2], "Doe");
db.CloseConn();
}
}