private void getAnnounce()// {
string mbPath = Server.MapPath("teaplate_new.htm");
Encoding code = Encoding.GetEncoding("gb2312");
string fileName ="Tailor_select.htm";
string strContent = "";
string str = null;
StreamReader sr = null;
StreamWriter sw = null;
try
{
sr = new StreamReader(mbPath, code);
str = sr.ReadToEnd(); }
catch (Exception ex)
{
throw ex;
}
finally
{
sr.Close();
}
string mySql = "select * from Tailor_select ";
DBConn myDB = new DBConn();
SqlDataReader mydr = myDB.getDataReader(mySql); strContent = "<script type=\"text/javascript\" src=\"../js/data_select.js\"></script><body topmargin=\"1\"><select name=\"select\" onclick=\"simOptionClick4IE()\"><option value=\"../index_three.html\" selected=\"selected\" class=\"error \" onClick=\"showOptionValue( this )\"> ...</option>"; while (mydr.Read())
{
string u = mydr["read_value"].ToString();
string v = mydr["read_name"].ToString();
strContent = strContent + "<option value='../" + u +"' onClick=\"showOptionValue(this, '" + u + "' )\" >" + v + "</option>\n"; }
strContent = strContent + "</select></body>";
mydr.Close();
myDB.Close();
try
{ sw = new StreamWriter(Server.MapPath("title_new/") + fileName, false, code);
sw.Write(strContent);
sw.Flush(); }
catch (Exception ex)
{
throw ex;
}
finally
{
sw.Close(); //在这提示错误 :未将对象引用设置到对象的实例。 在vs 2005中正常。在IIS中就错误。 } }
string mbPath = Server.MapPath("teaplate_new.htm");
Encoding code = Encoding.GetEncoding("gb2312");
string fileName ="Tailor_select.htm";
string strContent = "";
string str = null;
StreamReader sr = null;
StreamWriter sw = null;
try
{
sr = new StreamReader(mbPath, code);
str = sr.ReadToEnd(); }
catch (Exception ex)
{
throw ex;
}
finally
{
sr.Close();
}
string mySql = "select * from Tailor_select ";
DBConn myDB = new DBConn();
SqlDataReader mydr = myDB.getDataReader(mySql); strContent = "<script type=\"text/javascript\" src=\"../js/data_select.js\"></script><body topmargin=\"1\"><select name=\"select\" onclick=\"simOptionClick4IE()\"><option value=\"../index_three.html\" selected=\"selected\" class=\"error \" onClick=\"showOptionValue( this )\"> ...</option>"; while (mydr.Read())
{
string u = mydr["read_value"].ToString();
string v = mydr["read_name"].ToString();
strContent = strContent + "<option value='../" + u +"' onClick=\"showOptionValue(this, '" + u + "' )\" >" + v + "</option>\n"; }
strContent = strContent + "</select></body>";
mydr.Close();
myDB.Close();
try
{ sw = new StreamWriter(Server.MapPath("title_new/") + fileName, false, code);
sw.Write(strContent);
sw.Flush(); }
catch (Exception ex)
{
throw ex;
}
finally
{
sw.Close(); //在这提示错误 :未将对象引用设置到对象的实例。 在vs 2005中正常。在IIS中就错误。 } }
这里不对了
你看下你放的数据库的地方
你先用下绝对路经看下还没有没错
先把 Server.MapPath("title_new/") + fileName 输出出来,在iis上。看路径是否正确。