添加测试模拟帐号
上一篇 /
下一篇 2009-03-30 09:30:38
/ 个人分类:性能测试
创建一个简单的存储过程,向服务器用户表添加用户名为test1—test10000、密码为000共1万个用户。用sql存储过程向数据库添加,存储过程如下:
[-c.V
X8nvP3z3v{0Create Procedure myprc 51Testing软件测试网5YL(Bq r"Mg
as 51Testing软件测试网,N)nef5Y,K
declare @username varchar(50),@CName varchar(50),@i int,@y varchar(10)
$W
V8_,Ed]_yI0 set @username='test'
l E {+XZj(l[4V:u7O0 SET @i=1000051Testing软件测试网D1v-OhQ,H
WHILE( @i>=1)
vzSo)S"|1U+X*L0BEGIN
YJ9XtT nGO|0set @y=convert( varchar(10), @i)
I}aKz~-f_0 set @username=@username+@y51Testing软件测试网dS]u(k'H
insert into users(username,companyid,Password,CName) values (@username,'1','C6F057B86584942E415435FFB1FA93D4',@username) 51Testing软件测试网7]8c jxG+gF
set @y=''
ae_5m^I0 set @username='test'
,qd9iHh'TU0set @i=@i-151Testing软件测试网(u eF,GN+I
end51Testing软件测试网v\{;fO$?`'RRg
go
2X4\BfY
wBgh0
)tm{kpdS8g6ZaSI0用C#创建一个包含insert语句的文件file.txt,可以直接插入到表中51Testing软件测试网1y9KD&As ?c
using System;51Testing软件测试网oO7d Go%|
using System.IO;51Testing软件测试网)TX1\m+e
n\*z0z4z tY@_"n0class FileTest
Kc$m^7?(y(K6Fl0{51Testing软件测试网x e5I,t/dr
public static void Main()//String[] args)
$d|De Q0 {
C%Y_\6R5?!^0
l^nR0e-I
p_1e0 //写与读文件操作51Testing软件测试网$N~Q
Vk1K,TvgFo
StreamReader srd;51Testing软件测试网qlo%NZ*A$gBIE
StreamWriter swd;
m3jX@M4O@/k0 Directory.CreateDirectory("C:\\C#");51Testing软件测试网$_ p&lc#Ua~
swd = File.CreateText("C:\\C#\\file.txt");//创建或打开一个文件用于写入 UTF-8 编码的文本。
3r;Y-kbQc
F0 //打开追加的引以文件51Testing软件测试网h9x?5g^
// swd = File.AppendText("C:\\C#\\file.txt");
T` @f,a%}m)]5dqn2V%c0 // File.AppendAllText("C:\\C#\\file.txt", "1----------------------------1");51Testing软件测试网&~0V|3E3l M#S
//File.OpenText();51Testing软件测试网.WPD7uv/F
string aa = ",";
2}"op8M@j0 swd.WriteLine();
Q uqPg0 for (int i = 100; i > 1; i--)
L(wU?1cM0 {
5A,hlHA.P8Mon0 swd.WriteLine("insert into tablename('col1'{0}'col2') vaules('col1值{1}','col2值{2}')", aa, i, i);51Testing软件测试网
B
rAm'q)VqG&`
}51Testing软件测试网:oA2Yo.q/i
swd.Close();51Testing软件测试网8_IO7_f@E R
try
it#`f(I:]&A0 {
b8L&Cw.]
q#Z3n0 srd = File.OpenText("C:\\C#\\file.txt");
;OmK\b0 51Testing软件测试网-W1r
\1g1u]"ig
}
lfy IcT9B
a0 catch
RN{q/Zm^0 {
0k$`T6x;Db;U(y-P0 Console.WriteLine("file open failed");51Testing软件测试网WA\,L9?W6y
return;
.S*Y4^*IKM%s0 }51Testing软件测试网
yO6O.hUdQ(J|
while (srd.Peek() != -1)
+fHhl.q]/Xy/zL0 {
xjm\OF\j0 String str = srd.ReadLine();51Testing软件测试网5@6ff\9|1R3S
51Testing软件测试网
_c7p]1O!A~F
Console.WriteLine(str);51Testing软件测试网5\6]4S jv,[2y
}51Testing软件测试网/]m.k7nV mI8`g
Console.WriteLine("the end of the file has been reached");51Testing软件测试网@1f2iH9l:q
srd.Close();51Testing软件测试网!~;a| B]s1P%W
}
wO(Om:W5^[+Z:S0 51Testing软件测试网R7Qe!n0y
}51Testing软件测试网:{]B$qB4w2HK
51Testing软件测试网2mJ,N[4w0Tn
收藏
举报
TAG: