嵌入SQL语句
嵌入SQL语言:
我将一个sql链接到数据库,该数据库名为master(系统数据库)
then 给数据库添加新表,建立三个key:userid(int),name(char(10)),password(char(10))
在窗体中弄三个textbox控件,分别定义Name属性为userid,name,password;
再来一个button
以下是Form1.cs中的代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Runtime.InteropServices;
using System.Configuration;
namespace Str
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void submit_Click(object sender, EventArgs e)
{
/*
* connect to Sql Server
* 方法一:写在这里
*/
//string strConnection = "Data Source=ZRQ-PC;";
//strConnection += "Initial Catalog=master;Integrated Security=True";
// SqlConnection objConnection = new SqlConnection(strConnection);
/*
* 方法二:
* 这个方法为工程添加了新建项“应用程序配置文件”
* 将上面的那段写在App.config里
*/
string strConnection = ConfigurationSettings.AppSettings["connectionstring"];
SqlConnection objConnection = new SqlConnection(strConnection);
/************************************************************************/
if (name.Text == "")
MessageBox.Show("请输入姓名!", "提示", 0);
else
{
objConnection.Open();
SqlCommand cmd = new SqlCommand("select * from judging where userid='" + userid.Text.Trim() + "'", objConnection);
/*
***********************************************************************************************
相关文档:
这个逻辑关系乍看起来比较复杂,弄清楚了就好!
有两个表,
student(
id,
name,
primary key (id)
);
studentInfo(
id,
age,
address,
foreign key(id) references outTable(id) on delete cascade on update cascade
);
当我们删除student表的时候自然希望studentInfo里的相关信息也被删除,这就是外键起作用 ......
在网络上发送数据都会发生一些严重的安全问题,网络最大的担忧在于有人可以捕获数据,sqlserver支持采用证书来加密
1.创建证书
create master key encryption by
password = 'administrator123'
--用密码admini--
create certificate c1
encryption by password = 'administrator123'
with subject = 'c1 certific ......
功能:小写金额转换成大写
参数:@LowerMoney 小写金额 加上小数点最长可以保留38位
输出:大写金额
简介:SQL版 小写金额转换成大写金额(最多可以精确到小数点四位)
注: Decimal 数据类型最多可存储 38 个数字
转载:请保留以上信息,谢谢!!!
********************************* ......
本文转自:http://industry.ccidnet.com/art/1106/20070514/1080519_1.html
本文是SQL Server SQL语句优化系列文章的第一篇。该系列文章描述了在Micosoft’s SQLServer2000关系数据库管理系统中优化SELECT语句的基本技巧,我们讨论的技巧可在Microsoft's SQL Enterprise Manager或 Microsoft SQL Query Anal ......
用T-SQL做数据库分页查询也有好几年了,但对于各种查询方法的写法一至都没怎么去理会,最近参与了几个项目的开发,几个项目中分页查询的写法也不相同,这也让我产生了确认几种写法效率问题的兴趣。(注:我所说的几种写法都是需要返回总记录数的分页)
1、生成测试数据
select a.* into test from sys.columns a,sys.colu ......