最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net手机号码归属地查询代码
时间:2011-01-09 编辑:简简单单 来源:一聚教程网
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 手机号码所在地查询实现代码 01-02
- asp.net 中手机号码归属地查询实现代码 12-14
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18