目的:将字符串最后4位用*代替.字符串的长度不确定,好像SUBSTRING函数不能实现吧
解决方案 »
- 输入字符串的格式不正确,不知道错哪了 各位仁兄帮忙看看
- Repreter循环显示~~~~~~~的问题~~~~
- 身份验证方面的问题
- 请问:怎样将存放在App_Code文件夹中的公共类文件abc.cs转换为abc.dll?
- 实在没有分了,大家帮助下呀!有分马上送!我想在gridview上实现树装结构!
- 作了一个网站,一个页面出现问题后,再刷新或重新登录都出现同样的问题,但只要重新复制拷贝dll组件重新部署,就正常了!
- 用js修改dropdownlist的disabled=true时,Request.Form就取不到值,怎么办?
- 想系统学习ASP.NET需要学哪些东西?送100分
- 专为ASP.NET开发人员建立的群!1189190
- 请教DataGrid删除时间问题
- 求助:从表单取不出来值,上传的文件名得到的为空?
- 请教问题
找到最后的在用replace
string reValue = s.substring(0,s.length - 5 )+"****";
能不能直接在SQL中格式化呢,也就是说可不可以直接格式化Phone字段,以达到我的目的
SQL: select Phone,charge,.... from Bill where .....能不能给出具体的代码,谢谢了!!!
str = str.Substring(0,str.Length-4)+"****";//SDN****
substring(Phone,0,len(Phone)-3)+'****',
charge
from Bill where ///
用你的语句在SQL中运行没问题,但运行程序的时候报错
报错信息如下:
IErrorInfo.GetDescription failed with E_FAIL(0x80004005). string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
strConnection += "Data Source=";
strConnection += MapPath("database/Bill2008.mdb");
OleDbConnection conn = new OleDbConnection(strConnection);
string strsql = "SELECT Phone,startdate,starttime,duration,substring(Dialnumber,0,len(Dialnumber)-3)+'****' AS Dialnumber1,charge,type,destination FROM Bill WHERE typecode <> 9 AND startdate BETWEEN '" + this.txt_time_start.Text.Trim().ToString() + "' AND '" + this.txt_time_end.Text.Trim().ToString() + "' AND Phone BETWEEN '" + this.txt_phone_start.Text.Trim().ToString() + "' AND '" + this.txt_phone_end.Text.Trim().ToString() + "'";
OleDbCommand cmd = new OleDbCommand(strsql, conn);
conn.Open();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
this.GridView1.Visible = true;
this.GridView1.DataSource = ds.Tables[0].DefaultView;
this.GridView1.DataBind();
conn.Close();
正确如下:
string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
strConnection += "Data Source=";
strConnection += MapPath("database/Bill2008.mdb");
OleDbConnection conn = new OleDbConnection(strConnection);
string strsql = "SELECT Phone,startdate,starttime,duration,left(Dialnumber,len(Dialnumber)-3)+'****' AS Dialnumber1,charge,type,destination FROM Bill WHERE typecode <> 9 AND startdate BETWEEN '" + this.txt_time_start.Text.Trim().ToString() + "' AND '" + this.txt_time_end.Text.Trim().ToString() + "' AND Phone BETWEEN '" + this.txt_phone_start.Text.Trim().ToString() + "' AND '" + this.txt_phone_end.Text.Trim().ToString() + "'";
OleDbCommand cmd = new OleDbCommand(strsql, conn);
conn.Open();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
this.GridView1.Visible = true;
this.GridView1.DataSource = ds.Tables[0].DefaultView;
this.GridView1.DataBind();
conn.Close();