本文整理汇总了C#中DataClasses1DataContext.DatabaseExists方法的典型用法代码示例。如果您正苦于以下问题:C# DataClasses1DataContext.DatabaseExists方法的具体用法?C# DataClasses1DataContext.DatabaseExists怎么用?C# DataClasses1DataContext.DatabaseExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataClasses1DataContext
的用法示例。
在下文中一共展示了DataClasses1DataContext.DatabaseExists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: login
// Attempt to login to server with <username> and <password> and update the relevant global variables <username> and <connectionString>
public static bool login(string username, string password)
{
// Check if valid login
String connectionString = "Data Source=CPSLABSERVER\\TEAMPENGUIN;Initial Catalog=TeamPenguin;Persist Security Info=True;User ID=" + username + ";Password=" + password;
DataClasses1DataContext database = new DataClasses1DataContext(connectionString);
if (!database.DatabaseExists())
{
return false;
}
// set globals
Globals.connectionString = connectionString;
Globals.username = username;
// check if supervisor
try
{
SqlConnection sqlConnection1 = new SqlConnection(Globals.connectionString);
SqlCommand cmd = new SqlCommand();
cmd.CommandText = @"SELECT bulkadmin from sys.syslogins where name = '{UNAME}';".Replace("{UNAME}", username);
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
// set globals
Globals.isSupervisor = (1 == (int)cmd.ExecuteScalar());
sqlConnection1.Close();
}
catch (Exception ex)
{
return false;
}
return true;
}