asp.net手机号码归属地查询代码[网站编程]
本文“asp.net手机号码归属地查询代码[网站编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
create table t_phone
(
id int identity(1,1) not null primary key,
startno varchar(11) not null,
endno varchar(11) not null,
cityname nvarchar(50) not null
)用户查询
sqlconnection con = new sqlconnection(system.configuration.configurationmanager.connectionstrings["conn"].tostring());
con.open();
string strtestno = this.userphoneno.text.trim();
sqlcommand cmd = new sqlcommand();
cmd.connection = con;
cmd.commandtext = "select cityname from t_phone where startno<=@no and endno >=@no";
sqlparameter sp = new sqlparameter("@no", sqldbtype.varchar, 50);
sp.value = strtestno;
cmd.parameters.add(sp);
object ob = cmd.executescalar();
messagebox.show(ob.tostring());
代码.
1 using (sqlconnection con = new sqlconnection(system.configuration.configurationmanager.connectionstrings["conn"].tostring()))
2 {
3 sqlcommand cmd = new sqlcommand();
4 cmd.connection = con;
5 cmd.commandtext = "delete from t_phone";
6 if (con.state == connectionstate.closed)
7 {
8 con.open();
9
10 }
11 cmd.executenonquery();
12 if (folderbrowserdialog1.showdialog() == dialogresult.ok)
13 {
14 string strpath = this.folderbrowserdialog1.selectedpath;
15 string[] files = directory.getfiles(strpath, "*.txt", searchoption.topdirectoryonly);
16 string[] strs = new string[files.length];
17 int i = 0;
18 foreach (string var in files)
19 {
20 strs[i] = path.getfilenamewithoutextension(var);
21
22 string[] strtext = file.readalllines(var, encoding.default);
23 foreach (string var1 in strtext)
24 {
25 string[] strsplit = var1.split('-');
26 string strstartno = strsplit[0];
27 string strendno = strsplit[1];
28 string strcityname = strsplit[2];
29 cmd = new sqlcommand("insert into t_phone (startno,endno,cityname) values(@startno,@endno,@cityname)", con);
30 sqlparameter[] sp = new sqlparameter[3];
31 sp[0] = new sqlparameter("@startno", strstartno);
32 sp[1] = new sqlparameter("@endno", strendno);
33 sp[2] = new sqlparameter("@cityname", strs[i]+strcityname);
34 cmd.parameters.addrange(sp);
35 cmd.executenonquery();
36
37 }
38 i++;
39
40 }
41
42 }
43 }
以上是“asp.net手机号码归属地查询代码[网站编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |