在我开发的机器上好好的,往其它服务器的数据里更新都可以,当我把WEB应用程序转移到其它的机器上,配置好了之后,往数据库里写数据总是报错,SQLSERVER的认证模式也是混合模式,
<appSettings>
<add key="ZwRead" value="user id=sa;password=;Data Source=localhost;Initial Catalog=ship"/>
</appSettings>conn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ZwRead"]);
conn.Open();
string sql = string.Format("insert into Sailor values ('{0}','{1}',{2},'{3}','{4}','{5}','{6}','{7}',{8},{9},'{10}')",HeadId+EndId,txtName.Text,tonumber(txtId.Text),SailorZw,txtSfz.Text,ChangeToDateString(txtYxq.Text),txtDj.Text,txtZw.Text,tonumber(txtAge.Text),YesNo,txtDemo.Text);
SqlCommand com=new SqlCommand(sql,conn);
int exce=com.ExecuteNonQuery();
if(exce>0)
{
Response.Write("<script>alert('插入成功!');location.href='Default.aspx'</script>");
}
else
{
Response.Write("<script>alert('插入失败!');</script>");
}
conn.Close();
}
catch(Exception)
{
Response.Write("<script>alert('操作数据库错误!');</script>");
}
finally
{
}
<appSettings>
<add key="ZwRead" value="user id=sa;password=;Data Source=localhost;Initial Catalog=ship"/>
</appSettings>conn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ZwRead"]);
conn.Open();
string sql = string.Format("insert into Sailor values ('{0}','{1}',{2},'{3}','{4}','{5}','{6}','{7}',{8},{9},'{10}')",HeadId+EndId,txtName.Text,tonumber(txtId.Text),SailorZw,txtSfz.Text,ChangeToDateString(txtYxq.Text),txtDj.Text,txtZw.Text,tonumber(txtAge.Text),YesNo,txtDemo.Text);
SqlCommand com=new SqlCommand(sql,conn);
int exce=com.ExecuteNonQuery();
if(exce>0)
{
Response.Write("<script>alert('插入成功!');location.href='Default.aspx'</script>");
}
else
{
Response.Write("<script>alert('插入失败!');</script>");
}
conn.Close();
}
catch(Exception)
{
Response.Write("<script>alert('操作数据库错误!');</script>");
}
finally
{
}
这个USING没有
.conn定义出错,
。sql语句写错
<configSections>
<appSettings>
<add key="bbs" value="server=MaJorServer;User ID=sa;Password=;database=SrInforSys_bbs;Connection Reset=FALSE"></add>
</appSettings>
1、数据库是否和iis在同一台机子上。
2、你是用什么方法建的sql库。
3、SQLSERVER和IIS服务是用什么账户运行的。
4、是否在sqlserver库中添加的可供IIS访问的账户。
5、IE的出错信息。
delphi,asp.net,C#,j2me,软件工程,企业管理