见 http://code.google.com/p/mmdbsolution/source/browse/trunk/+mmdbsolution+--username+SiliangDu1987%40gmail.com/DBTest/DBTest/Default.aspx.cs?spec=svn206&r=206

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using FdbDataProvider; namespace DBTest
{
public partial class _Default : System.Web.UI.Page
{
Random r;
SqlConnection sqlConn;
FdbConnection fdbConn;
//SqlCommand sqlCmd;
//FdbCommand fdbCmd;
static int maxIndex = 0; protected void Page_Load(object sender, EventArgs e)
{
r = new Random();
sqlConn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|"
+ @"\SqlServerDB.mdf;Integrated Security=True;User Instance=True");
//sqlConn = new SqlConnection(@"Data Source=SILEAS-PC\SQLFORFASTDB;initial catalog=test;uid=sa;pwd=ss1022");
fdbConn = new FdbConnection(@"DataSource=test.fdb",
FdbConnection.DefaultInitDatabaseSize * 2,
FdbConnection.DefaultInitIndexSize * 2,
FdbConnection.DefaultExtensionQuantum * 2);
//SqlDataSource1.SelectCommand = "SELECT * FROM test";
//SqlDataSource1.Select(new DataSourceSelectArguments());
//maxIndex = ListView1.Items.Count; if (TbxInsert.Text == "")
{
try
{
sqlConn.Open();
fdbConn.Open(); SqlCommand sqlCmd = sqlConn.CreateCommand();
sqlCmd.CommandText = "delete from persons"; FdbCommand fdbCmd = fdbConn.CreateCommand();
fdbCmd.CommandText = "delete from persons"; //where salary>=0"; sqlCmd.ExecuteNonQuery(); fdbCmd.ExecuteNonQuery(); maxIndex = 0;
}
catch (Exception ex)
{
LblError.Text = ex.Message;
}
finally
{
if (sqlConn.State == ConnectionState.Open)
sqlConn.Close();
if (fdbConn.State == ConnectionState.Open)
fdbConn.Close();
}
}
else
{
//maxIndex = Convert.ToInt32(TbxInsert.Text);
}
} protected void BtnSelect_Click(object sender, EventArgs e)
{
try
{
int loopCount = Convert.ToInt32(TbxCount.Text);
int randName;
DateTime startTime, endTime;
TimeSpan d; sqlConn.Open();
LbxSelect.Items.Clear();
LbxDes.Items.Clear(); startTime = DateTime.Now;
for (int i = 0; i < loopCount; ++i)
{
randName = r.Next(0, maxIndex);
SqlCommand sqlCmd = sqlConn.CreateCommand();
//SqlDataSource1.SelectCommand = "SELECT * FROM test WHERE name=" + randName.ToString();
//SqlDataSource1.Select(new DataSourceSelectArguments());
sqlCmd.CommandText = "SELECT * FROM persons WHERE name=" + randName.ToString(); //sqlCmd.ExecuteNonQuery();
//LbxSelect.Items.Add(i.ToString()); SqlDataReader reader = sqlCmd.ExecuteReader(); while (reader.Read())
{
LbxSelect.Items.Add(reader["name"].ToString());
//LbxDes.Items.Add(reader["address"].ToString());
}
reader.Close();
}
endTime = DateTime.Now;
d = endTime - startTime;
LblTime.Text = d.Seconds.ToString() + "秒" + d.Milliseconds.ToString() + "毫秒";
LblError.Text = "SQL Server select successfully!";
}
catch (Exception ex)
{
if (TbxCount.Text == "")
LblError.Text = "请输入查询次数!";
else
LblError.Text = ex.Message;
}
finally
{
sqlConn.Close();
}
} protected void BtnInsert_Click(object sender, EventArgs e)
{
try
{ int count = Convert.ToInt32(TbxInsert.Text), n = 0;
DateTime startTime, endTime;
TimeSpan d;
SqlCommand sqlCmd = sqlConn.CreateCommand();
sqlConn.Open(); startTime = DateTime.Now;
for (int i = 0; i < count; ++i)
{
//SqlCommand sqlCmd = sqlConn.CreateCommand();
sqlCmd.CommandText = "insert into persons(name,salary,address) "
+ "values(" + i.ToString() + "," + i.ToString() + ",'" + TbxDes.Text + "')"; //sqlCmd.CommandText = @"insert into persons(name,salary,address) "
// + @"values(@name,@salary,@address)";
////if (i == 0)
////{
// sqlCmd.Parameters.Add("name", SqlDbType.Int);
// sqlCmd.Parameters.Add("salary", SqlDbType.Real);
// sqlCmd.Parameters.Add("address", SqlDbType.NChar);
////} //sqlCmd.Parameters["name"].Value = i;
//sqlCmd.Parameters["salary"].Value = i;
//sqlCmd.Parameters["address"].Value = "'"+TbxDes.Text+"'"; n += sqlCmd.ExecuteNonQuery();
//SqlDataSource1.InsertCommand = "INSERT INTO test(name, salary, description) "
// + "VALUES (" + i.ToString() + ", " + i.ToString() + ", '" + TbxDes.Text + "')";
//SqlDataSource1.Insert();
}
endTime = DateTime.Now;
d = endTime - startTime;
LblTime.Text = d.Seconds.ToString() + "秒" + d.Milliseconds.ToString() + "毫秒";
maxIndex = Convert.ToInt32(TbxInsert.Text); LblError.Text = "SQL Server Insert " + n.ToString() + " records successfully!";
//maxIndex += count;
}
catch (Exception ex)
{
LblError.Text = ex.Message;
}
finally
{
sqlConn.Close();
}
} protected void BtnClr_Click(object sender, EventArgs e)
{
try
{
sqlConn.Open();
SqlCommand sqlCmd = new SqlCommand("DELETE from persons", sqlConn);
int n = sqlCmd.ExecuteNonQuery();
//SqlDataSource1.DeleteCommand = "DELETE from test";
//SqlDataSource1.Delete();
LblError.Text = "SQL Server Clear " + n.ToString() + " records successfully!"; //maxIndex = 0;
}
catch (Exception ex)
{
LblError.Text = ex.Message;
}
finally
{
sqlConn.Close();
}
} //public void FdbCreateTable(FdbConnection connection, FdbCommand command, string name, string[] attr, string[] attrType)
//{
// try
// {
// for (int i = 0; i < attr.Length; ++i)
// {
// CLI.FieldType type; // switch (attr[i])
// {
// case "int": type = CLI.FieldType.cli_int8; break;
// case "real": type = CLI.FieldType.cli_real8; break;
// case "string": type = CLI.FieldType.cli_asciiz; break;
// }
// command.Fields.Add(attr[i], type);
// }
// if (connection.CreateTable(name, command.Fields) >= 0)
// throw new Exception("Cannot create table in FastDB");
// }
// catch (Exception ex)
// {
// LblError.Text = ex.Message;
// }
//} protected void BtnInsertFdb_Click(object sender, EventArgs e)
{
try
{
int count = Convert.ToInt32(TbxInsert.Text), n = 0;
DateTime startTime, endTime;
TimeSpan d;
FdbCommand fdbCmd = fdbConn.CreateCommand();
fdbConn.Open(); startTime = DateTime.Now;
for (int i = 1; i <= count; ++i)
{
//FdbCommand fdbCmd = fdbConn.CreateCommand();
//fdbCmd.CommandText = @"insert into persons(name,salary,address) "
// + @"values(%name,%salary,%address)";
////if (i == 0)
////{
//fdbCmd.Parameters.Add("name", CLI.FieldType.cli_int8, CLI.FieldFlags.cli_indexed);
//fdbCmd.Parameters.Add("salary", CLI.FieldType.cli_int8);
//fdbCmd.Parameters.Add("address", CLI.FieldType.cli_asciiz);
////} //fdbCmd.Parameters["name"].asInt64 = i;
//fdbCmd.Parameters["salary"].asInt64 = i;
//fdbCmd.Parameters["address"].asString = TbxDes.Text; fdbCmd.CommandText = "Insert into persons(name,salary,address) "
+ "values(" + i.ToString() + "," + i.ToString() + ",'" + TbxDes.Text + "')"; n += fdbCmd.ExecuteNonQuery();
}
endTime = DateTime.Now;
d = endTime - startTime;
LblTimeFdb.Text = d.Seconds.ToString() + "秒" + d.Milliseconds.ToString() + "毫秒";
maxIndex = Convert.ToInt32(TbxInsert.Text); LblError.Text = "FastDB Insert " + n.ToString() + " records successfully!";
//maxIndex += count;
}
catch (Exception ex)
{
LblError.Text = ex.Message;
}
finally
{
fdbConn.Close();
}
} protected void BtnSelectFdb_Click(object sender, EventArgs e)
{
try
{
int loopCount = Convert.ToInt32(TbxCount.Text);
int randName;
DateTime startTime, endTime;
TimeSpan d; LbxSelectFdb.Items.Clear();
LbxDesFdb.Items.Clear();
fdbConn.Open(); startTime = DateTime.Now;
for (int i = 0; i < loopCount; ++i)
{
randName = r.Next(0, maxIndex);
//SqlDataSource1.SelectCommand = "SELECT * FROM test WHERE name=" + randName.ToString();
//SqlDataSource1.Select(new DataSourceSelectArguments());
//LbxSelectFdb.Items.Add(randName.ToString());
//LbxDesFdb.Items.Add(TbxDes.Text);
FdbCommand fdbCmd = fdbConn.CreateCommand();
fdbCmd.CommandText = "select * from persons where name=" + randName.ToString(); //fdbCmd.ExecuteNonQuery();
//LbxSelectFdb.Items.Add(i.ToString()); FdbDataReader reader = fdbCmd.ExecuteReader();
while (reader.Read())
{
LbxSelectFdb.Items.Add(reader["name"].ToString());
//LbxDesFdb.Items.Add(reader["address"].ToString());
}
reader.Close();
}
endTime = DateTime.Now;
d = endTime - startTime;
LblTimeFdb.Text = d.Seconds.ToString() + "秒" + d.Milliseconds.ToString() + "毫秒";
LblError.Text = "FastDB Select successfully!";
}
catch (Exception ex)
{
if (TbxCount.Text == "")
LblError.Text = "请输入查询次数!";
else
LblError.Text = ex.Message;
}
finally
{
fdbConn.Close();
}
} protected void BtnClrFdb_Click(object sender, EventArgs e)
{
try
{
FdbCommand fdbCmd = fdbConn.CreateCommand();
fdbCmd.CommandText = "delete from persons where salary >= 0";
fdbConn.Open(); int n = fdbCmd.ExecuteNonQuery();
//SqlDataSource1.DeleteCommand = "DELETE from test";
//SqlDataSource1.Delete();
LblError.Text = "FastDB clear " + n.ToString() + " records successfully!"; //maxIndex = 0;
}
catch (Exception ex)
{
LblError.Text = ex.Message;
}
finally
{
fdbConn.Close();
}
} }
}

  

fast db 学习的更多相关文章

  1. Fast RCNN 学习

    因为项目需要,之前没有接触过深度学习的东西,现在需要学习Fast RCNN这个方法. 一步步来,先跟着做,然后再学习理论 Fast RCNN 训练自己数据集 (1编译配置) Fast RCNN 训练自 ...

  2. Fast R-CNN学习总结

    Fast R-CNN是R-CNN的改良版,同时也吸取了SPP-net中的方法.在此做一下总结. 论文中讲到在训练阶段,训练一个深度目标检测网络(VGG16),训练速度要比R-CNN快9倍左右,比SPP ...

  3. 五分钟秒懂Java日志组件

    Java中有许多种日志记录方式,有些API有占位符,有些API没占位符,初学的人可能会搞不清楚这些日志组件的由来.我一开始的时候也是很懵逼的,后来一点点弄懂了于是就又了这篇文章. 在Java中进行日志 ...

  4. mongoDB 文档操作_改

    mongoDB 更改操作 格式对比 MySQL update table set .... where .... db.collection.updateOne(query,update,upsert ...

  5. Quadro P5200 - 最强大的移动工作站显卡 专门为了惠普 VR Z 背包电脑而发布

    https://www.leiphone.com/news/201708/Z1MCetuoobEaHIqa.html 前言 在今年的计算机图形技术顶会 SIGGRAPH,英伟达并不是在单纯地展示自家的 ...

  6. FTP的搭建过程,以及遇到的坑

    在之前的博客中,我有说到,我最喜欢用Yum在线安装的方式安装软件,简单省事儿.现在看来,也不尽然,关键是,无法快速找到我要的文件,整个whereis 也很累.所以,现在觉得,还是乖乖的整个压缩包,自行 ...

  7. torch.nn 的本质

    torch.nn 的本质 PyTorch 提供了各种优雅设计的 modules 和类 torch.nn,torch.optim,Dataset 和 DataLoader 来帮助你创建并训练神经网络.为 ...

  8. Android学习笔记之Fast Json的使用

    PS:最近这两天发现了Fast Json 感觉实在是强大.. 学习内容: 1.什么是Fast Json 2.如何使用Fast Json 3.Fast Json的相关原理 4.Fast Json的优势, ...

  9. Deep Learning 17:DBN的学习_读论文“A fast learning algorithm for deep belief nets”的总结

    1.论文“A fast learning algorithm for deep belief nets”的“explaining away”现象的解释: 见:Explaining Away的简单理解 ...

随机推荐

  1. 能看到U盘占用内存,但看不到文件

    原因:是u盘感染了病毒 .病毒把U盘里的东西加上了隐藏属性和系统属性. 解决办法:1.在“运行”里面输入:cmd,回车:2.在cmd中进入U盘.比如你的U盘是H盘,就输入:h:,回车:3.进入U盘之后 ...

  2. ASP.NET MVC学习之模型验证篇

    一.学习前的一句话 在这里要先感谢那些能够点开我随笔的博友们.慢慢的已经在博客园中度过一年半了,伊始只是将博客园作为自己学习的记录本一样使用,也不敢将自己的随笔发表到博客园首页,生怕自己的技艺不高,反 ...

  3. Linux(Red Hat 6 32位) 下安装Mysql5.6.30

    转载地址:http://my.oschina.net/fusxian/blog/300480 1. 下载MySQL 5.6 下载页面:http://dev.mysql.com/downloads/my ...

  4. JavaScript获取onclick、onchange等事件的值

    今天小菜处理下拉菜单级联问题时,想获取HTML标签中某个事件的内容,也就是值,比如从<select id="city" onchange="javascript:t ...

  5. SpringMVC从一个controller跳转到另一个controller

    return "redirect:……路径……"; @RequestMapping(value = "/index", method = RequestMeth ...

  6. CSS Sticky Footer: 完美的CSS绝对底部

    CSS的简单在于它易学,CSS的困难在于寻找更好的解决方案.在CSS的世界里,似乎没有完美这种说法.所以,现在介绍的CSS绝对底部,只是目前个人见过的方案中比较完美的吧. 先说我们为什么会使用到这个C ...

  7. centos安装firefox flash插件

    centos下的firefox flash插件默认不是最新版的,安装过程如下: 将安装地址添加到repolist中 sudo yum -y install http://linuxdownload.a ...

  8. paip.配置ef_unified_filter() failed ext_filter_module mod_ext_filter.so apache 错误解决

    paip.配置ef_unified_filter() failed  ext_filter_module  mod_ext_filter.so apache 错误解决 作者Attilax  艾龙,   ...

  9. 更新日志 - BugHD 与你的应用一起成长

    上周 BugHD Android客户端上线了,下载地址在此,欢迎大家体验并提出反馈.本周增加 BugHD 和 fir.im 的新功能,同时也做出一些体验优化. BugHD 新增功能 1.新增安装量.启 ...

  10. 苹果App Store审核指南中文翻译(2014.9.1更新)

    转:http://www.cocoachina.com/appstore/20140901/9500.html CocoaChina对<苹果应用商店审核指南>中文翻译最近一次更新时间为20 ...