C# winfrom数据库备份与恢复通过C# winfrom来对SQL数据库进行数据库的备份和还原图1图2 //设置保存的路径private void btnBaoCun_Click(object sender, EventArgs e){FolderBrowserDialog myFolderBrowserDialog = new FolderBrowserDialog();//设置根目录在桌面;myFolderBrowserDialog.RootFolder = System.Environment.SpecialFolder.Desktop;//设置当前选择的路径myFolderBrowserDialog.SelectedPath = "C:";//允许在对话框中...
考虑到代码的安全性,已经修改起来的方便性,我们常常不会将数据库连接字符串直接放在代码中,而是将这个字符串放到一个App.config配置文件中,赋值给一个变量,然后再在代码中引用这个变量。 具体做法如下: ①右键项目名称,新建一个“应用程序配置文件”改名为App.config。 ②在App.config中添加如下代码1 <configuration>
2 <connectionStrings>
3 <add name="myconnStr" connectionString="Data Source=PC201507182002\...
如上图所示界面,当我们点击保存按钮时将会将表格中的数据保存到数据库中去,与数据库进行一个交互 第一步我们就是要获取到表格中的数据string pwd = textpwd.Text; //获得第一次输入密码string agePqd = txtsurepwd.Text; //获得第二次输入的密码string name = textname.Text; //获得用户输入的名字 int grendID = Change(); //获得用户输入年级string phone = textphone.Text; //获得用户输入的...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace 电子商务
{publicpartialclass Form1 : Form{public Form1(){InitializeComponent();}privatevoid Form1_Load(object sender, EventArgs e){}privatevoid bu...
MySQL安装好了,今天跟大家交流一下怎么利用EntityFramework的CodeFirst在MySQL数据库中创建数据库目标框架:.NET Framework 4第一步:新建一个项目,然后添加如下的引用,这些引用可以在NuGet中添加,也可以到官网中下载然后添加第二步:在配置文件中添加数据库节点配置<span style="font-family:Arial;font-size:10px;"><?xml version="1.0"?>
<configuration><startup> <supportedRuntime version="v4.0" sku=".NETFramework,Ve...
1、常用的T-Sql语句 查询:SELECT * FROM tb_test WHERE ID=‘1‘ AND name=‘xia‘ SELECT * FROM tb_test 插入:INSERT INTO tb_test VALUES(‘xia‘,‘123‘) INSERT INTO tb_test(name) VALUES(‘xia‘) 更新:UPDATE tb_test SET password=‘234‘ WHERE ID=‘1‘ 删除:DELETE FROM tb_test WHERE ID=‘1‘ DELETE tb_test WHERE ID=‘1‘2、在vs201...
使用DataSet对象访问数据库 当对DataSet对象进行操作时,DataSet对象会产生副本,所以对DataSet里的数据进行编辑操作不会直接对数据库产生影响,而是将DataRow的状态设置为added、deleted或changed,最终的更新数据源动作将通过DataAdapter对象的update方法来完成。 DataSet对象的常用方法如下。void AcceptChanges():该方法用来提交DataSet里的数据变化。void clear():该方法用来清空DataSet里的内容。DataSet copy():该...
方法1:将图片复制到指定文件夹,在数据库中存储图片路径,通过读取路径来显示图片。string str;privatevoid toolStripButton1_Click(object sender, EventArgs e){if (openFileDialog1.ShowDialog() == DialogResult.OK){str = openFileDialog1.FileName;pictureBox1.Image = Image.FromFile(str);}}//打开文件并在PictureBox中显示图片privatevoid toolStripButton2_Click(object sender, EventArgs e){string filename = DateTi...
1.在用windows模式登陆sql server 数据库 简历一个student的数据库,然后新建查询:createtable student
(id int auto_increment primarykey,name char(10) notnull,sex char(10) notnull,age char(10) notnull,
)2.在vs中新建一个项目,输入一下代码:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data...
用第三方组件:NPOI来实现先去官网:http://npoi.codeplex.com/下载需要引入dll(可以选择.net2.0或者.net4.0的dll),然后在网站中添加引用。使用 NPOI 你就可以在没有安装 Office 或者相应环境的机器上对 WORD/EXCEL 文档进行读写。创建一个实体类:[Table("Customer") ]publicclass Customer{[Key]publicint Id { get; set; }publicstring FirstName { get; set; }publicstring LastName { get; set; }publicint Age { get; set...
一:引用MySQL使用基于Parameter方式代码,总是提示:“Column ‘列名‘cannot be null”解决 MySQL使用基于Parameter方式代码,总是提示:“Column ‘列名‘ cannot be null” 解决方法1:直接在连接字符串里面加一个 oldsyntax=true 即可。 例如:
?1server=127.0.0.1;userid=root;password=;database=itemdb;oldsyntax=true 解决方法2:将语句中的 @ 替换为 ? 例如: ?1234567891011121314151617StringBuilder strSql=new Strin...
SqlConnection:对SQL Server 数据库的连接构造函数:SqlConnection(): 初始化 SqlConnection 类的新实例。方法:Open(): 打开一个数据库连接CreateCommand(): 创建并返回与 SqlConnection 关联的 SqlCommand 对象BeginTransaction():开始数据库事务SqlCommand:对SQL Server 数据库执行的一个 Transact-SQL 语句或存储过程属性:CommandTimeout: 获取或设置在终止尝试执行命令并生成错误之前的等待时,默认值为 30 秒SqlTr...
代码生成器进行了改进,针对Oracle数据库生成更优美的代码。这样生成出来的代码,更像微软的风格,更像C#.NET的标准规范,阅读起来也更优美。把Oracle表字段名默认大写, 有_分割等进行了优化,这样用我们代码生成器生成的代码,阅读起来,更顺眼。更能拿得出手了。代码生成器生成代码效率高、规范性强、错误少、质量可靠。EF 生成的 Oracle 底层数据库的SQL语句性能不能有保障、在大并发大用户时会有很多不确定因素、甚至优化起来...
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Configuration;using System.Data;using System.Data.SqlClient;namespace 登录.DAL{ public static class SqlHelper { private static readonly string conStr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString; //执行增删改的 public static ...
数据库创建“用户表”“角色表”“用户角色关系表”create table roles
(
RId int identity,
RName varchar(50),
Remark varchar(50)
)
create table UserRole
(
Users_UId int,
roles_Rid int
)
create table Users
(
UId int identity,
UName varchar(50),
UPwd varchar(50)
)数据库创建一个view视图create view USER_SHOW
AS
select RName,RId,UName,UId from Users join UserRole on Users.UId=UserRole.Users_UId join roles ...