Object[] params = {id,name}
public int executeSQL(String sql,Object[] params){
PreparedStatement psmt =conn.prepareStatement(sql)
if(params != null){
for(int i = 0 i<params.lengthi++){
psmt.setObject((i+1),params[i])
}
}
}
修改web.config的方法2007-05-07 14:23最早学.net代码时,修改web.config,直接绑定到table里去就好了。。代码如下:
读
Dim ds As DataSet
ds = New DataSet()
ds.ReadXml(Server.MapPath("web.config"))
setname.Text = ds.Tables(1).Rows(0)(1)
addr.Text = ds.Tables(1).Rows(1)(1)
wangzhi.Text = ds.Tables(1).Rows(2)(1)
tel.Text = ds.Tables(1).Rows(3)(1)
email.Text = ds.Tables(1).Rows(4)(1)
ds.Clear()
ds.Dispose()
改
Dim ds As DataSet
ds = New DataSet()
ds.ReadXml(Server.MapPath("web.config"))
ds.Tables(1).Rows(0)(1) = setname.Text
ds.Tables(1).Rows(1)(1) = addr.Text
ds.Tables(1).Rows(2)(1) = wangzhi.Text
ds.Tables(1).Rows(3)(1) = tel.Text
ds.Tables(1).Rows(4)(1) = email.Text
ds.AcceptChanges()
ds.WriteXml(Server.MapPath("web.config"))
ds.Clear()
ds.Dispose()
msg.Text = "修改成功!"
最近做项目,用上了静态刷新,研究了下ajax,阿哦,要在web.config里加上一句话
<httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
</httpHandlers>
用上面的读取就完蛋了。。
怎么办?来个最恶心的做法吧。。。
读:
etname.Text = ConfigurationSettings.AppSettings("website")
addr.Text = ConfigurationSettings.AppSettings("addr")
wangzhi.Text = ConfigurationSettings.AppSettings("url")
tel.Text = ConfigurationSettings.AppSettings("tel")
email.Text = ConfigurationSettings.AppSettings("email")
Dim zt As Integer = ConfigurationSettings.AppSettings("denglu_rizhi")
改:
Dim XPath As String = "/configuration/appSettings/add[@key='?']"
Dim domWebConfig As New XmlDocument
domWebConfig.Load(HttpContext.Current.Server.MapPath("web.config"))
Dim websites As XmlNode = domWebConfig.SelectSingleNode(XPath.Replace("?", "website"))
websites.Attributes("value").InnerText = setname.Text
Dim addrs As XmlNode = domWebConfig.SelectSingleNode(XPath.Replace("?", "addr"))
addrs.Attributes("value").InnerText = addr.Text
Dim wangzhis As XmlNode = domWebConfig.SelectSingleNode(XPath.Replace("?", "url"))
wangzhis.Attributes("value").InnerText = wangzhi.Text
Dim tels As XmlNode = domWebConfig.SelectSingleNode(XPath.Replace("?", "tel"))
tels.Attributes("value").InnerText = tel.Text
Dim emails As XmlNode = domWebConfig.SelectSingleNode(XPath.Replace("?", "email"))
emails.Attributes("value").InnerText = email.Text
domWebConfig.Save(HttpContext.Current.Server.MapPath("web.config"))
msg.Text = "修改成功!"
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)