本文整理汇总了C#中Connection.Exec方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.Exec方法的具体用法?C# Connection.Exec怎么用?C# Connection.Exec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.Exec方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillUserTable
protected void FillUserTable(Connection db)
{
string sql = "INSERT INTO `user` (`name`, `username`, `email`) VALUES('myname', 'myusername', '[email protected]');";
db.Exec(sql);
sql = "INSERT INTO `user` (`name`, `username`, `email`) VALUES('myname2', 'myusername2', '[email protected]');";
db.Exec(sql);
sql = "INSERT INTO `user` (`name`, `username`, `email`) VALUES('myname3', 'myusername3', '[email protected]');";
db.Exec(sql);
}
示例2: CreateUserTable
protected void CreateUserTable(Connection db)
{
db.Exec("DROP TABLE IF EXISTS `user`;");
string sql = "CREATE TABLE `user` ( " +
"`id` int(11) NOT NULL AUTO_INCREMENT, " +
"`name` varchar(255) NOT NULL, " +
"`username` varchar(255) NOT NULL, " +
"`email` varchar(255) NOT NULL, " +
"PRIMARY KEY(`id`)" +
") ENGINE = MEMORY DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;";
db.Exec(sql);
}
示例3: CreateMetaTable
protected void CreateMetaTable(Connection db)
{
db.Exec("DROP TABLE IF EXISTS `meta`;");
string sql = "CREATE TABLE `meta` ( " +
"`id` int(11) NOT NULL AUTO_INCREMENT, " +
"`meta_key` varchar(255) NOT NULL, " +
"`meta_value` varchar(8000) DEFAULT NULL, " +
"PRIMARY KEY(`id`)," +
"KEY `meta_key` (`meta_key`) " +
") ENGINE = MEMORY DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;";
db.Exec(sql);
}