添加测试模拟帐号
上一篇 /
下一篇 2009-03-30 09:30:38
/ 个人分类:性能测试
创建一个简单的存储过程,向服务器用户表添加用户名为test1—test10000、密码为000共1万个用户。用sql存储过程向数据库添加,存储过程如下:51Testing软件测试网^A;F^gmYV5}
Create Procedure myprc
v"NE`4hv3R/c0 as
K(f-rJ8t$rv5u`0 declare @username varchar(50),@CName varchar(50),@i int,@y varchar(10)
3f!L
Gf$iqo0 set @username='test'
+z~iD o,e0 SET @i=1000051Testing软件测试网*M]Ocu[J#~2e!A
WHILE( @i>=1)51Testing软件测试网_)^
N4M/W
BEGIN51Testing软件测试网
? D4b[&l+y%AJ
set @y=convert( varchar(10), @i)
3en^*sJ0 set @username=@username+@y
;PY_caInAQ0 insert into users(username,companyid,Password,CName) values (@username,'1','C6F057B86584942E415435FFB1FA93D4',@username) 51Testing软件测试网i.Apj
_!QLE'q
a,x
set @y=''
"V#E!Qw] JIR3~0 set @username='test'51Testing软件测试网d1V4DMP3J
set @i=@i-1
4JCwxo
f6a0end
\y
J,Gk!^!{a m'Z0 go51Testing软件测试网"w[A'nus
z7gv
51Testing软件测试网[};kQ w
用C#创建一个包含insert语句的文件file.txt,可以直接插入到表中51Testing软件测试网 |o^?T:Q&?
using System;
y:es
T$VD"~8M%K0using System.IO;
;M7uB6a%@%k_!?0Le051Testing软件测试网fPv7h:A1}'N{
class FileTest
D0Z R/s"w0{51Testing软件测试网e0azG|
public static void Main()//String[] args)51Testing软件测试网p2VXP
Haj8T
{
[ zvK7ehvFz;A051Testing软件测试网.C0I@e1tl
Vew@
//写与读文件操作
F\$Y0_1j0`0 StreamReader srd;
B%L j/b;b-h+vu0 StreamWriter swd;
+w7x:d&~"J*N?0 Directory.CreateDirectory("C:\\C#");
^Ot&j*Z0 swd = File.CreateText("C:\\C#\\file.txt");//创建或打开一个文件用于写入 UTF-8 编码的文本。51Testing软件测试网&MG1|k0[.aB[
//打开追加的引以文件51Testing软件测试网Z$^*jp@2mU
// swd = File.AppendText("C:\\C#\\file.txt");51Testing软件测试网5\xQW2z
// File.AppendAllText("C:\\C#\\file.txt", "1----------------------------1");51Testing软件测试网p6GJ0i3f$i!dw$~,W
//File.OpenText();51Testing软件测试网+T@!eeN
@
string aa = ",";
$C(U%["` pIwSm0 swd.WriteLine();51Testing软件测试网Rv$co4h
for (int i = 100; i > 1; i--)
9c2G#~)sH0 {
$az+p,@t+f
iQK$^0 swd.WriteLine("insert into tablename('col1'{0}'col2') vaules('col1值{1}','col2值{2}')", aa, i, i);
&G-C:e/Qx8U)~C0 }
uf n#^kS0sF0 swd.Close();51Testing软件测试网U0}*}^%|
try51Testing软件测试网 Hdy-HD
{51Testing软件测试网D)j;F*Ob~
srd = File.OpenText("C:\\C#\\file.txt");
g6~&z
WmEep&L0
+W3I*_
Ot1}1{0 }51Testing软件测试网|V(j'S }Xm(q"ii
catch
xo$w:[!Q I8Dg0 {51Testing软件测试网)JR5gtpIRbEAZlU
Console.WriteLine("file open failed");
7D3_R3^vL
Km0 return;
"g!}Q\}4mz0 }51Testing软件测试网;\"}B$aHYc3Y1N4s
while (srd.Peek() != -1)51Testing软件测试网%Z
L/yW+B7T
X
{51Testing软件测试网 o(U3`#{/TY2{
String str = srd.ReadLine();
|{7W:VBo0 51Testing软件测试网hhdlu&\*V ?
Console.WriteLine(str);51Testing软件测试网:kje5sx\/V M_
}51Testing软件测试网
Q;SZ8x$k4v'y,}
Console.WriteLine("the end of the file has been reached");51Testing软件测试网?i%\:M4w9R-u^
srd.Close();
OT;~a4xI~C0 }
Tm9a,pF3Ai@q0
H4IE-~2|0}51Testing软件测试网*K!SROR.Zr%a^+~
51Testing软件测试网;BS2@kmbQ
收藏
举报
TAG: