我的程序在本地测试过没问题,担放到空间上却只能查找和更新数据,却不能插入和删除数据,何解?

sunou5 2006-09-20 01:13:43
以下是部分代码:

//提交数据
private void submitButton_Click(object sender, System.EventArgs e)
{
//将数据插入数据库
string insertPhotoNewsCommandString = "Insert Into LastInformation " +
"(LastInformationTitle,LastInformationContent,LastInformationSource,NewsTypeID,NewsType)" +
" Values ('" + lastInformationTitleTextBox.Text.Trim() + "','" + WebHtmlEditor1.Html.Trim() + "','" +
informationSourceTextbox.Text.Trim() + "'," + newsTypeDropDownList.SelectedItem.Value.ToString() + ",'" +
newsTypeDropDownList.SelectedItem.Text.Trim() + "')";

OleDbConnection commonOleDbConnection = new OleDbConnection(strConnectionString);
OleDbCommand insertPhotoNewsCommand = new OleDbCommand(insertPhotoNewsCommandString,commonOleDbConnection);

commonOleDbConnection.Open();
insertPhotoNewsCommand.ExecuteNonQuery();
commonOleDbConnection.Close();

Response.Write("<script>alert('数据已被成功提交!')</script>");
lastInformationTitleTextBox.Text = String.Empty;
WebHtmlEditor1.Html = String.Empty;
informationSourceTextbox.Text = String.Empty;
}

我用的是VS03+ACCESS,出错提示信息为:INSERT INTO 语句的语法错误。
...全文
116 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunou5 2006-09-20
  • 打赏
  • 举报
回复
叫空间的管理员帮忙设置了权限还是不行,后来用VS03重新编译Release版的.Dll,上传后问题解决了。
cabee 2006-09-20
  • 打赏
  • 举报
回复
叫空间的管理员帮你设置权限吧
dapanda 2006-09-20
  • 打赏
  • 举报
回复
放数据库的文件夹没有写的权限,以前我也调了半天才发现。
nimeide1234567890 2006-09-20
  • 打赏
  • 举报
回复
public void Button1_Click(Object Source, EventArgs e)
{

if(product_no.Text.ToString()=="" || shipment_date.Text.ToString()=="")
{
lbl_message.Text ="<img src='../images/no.gif' border=0><font color=red>產品號不能爲空</font>";
}
else
{
string nowDSN=ConfigurationSettings.AppSettings["produce1"];
SqlConnection myConnection=new SqlConnection(nowDSN);
string CommandText;
SqlCommand myCommand = new SqlCommand();
myCommand.Connection=myConnection;
myCommand.Connection.Open();

myCommand.CommandText = "insert into product(order_no,customer,department_no,product_no,shipment_date,state2,remark,product_nameplate,orderform_sum,accomplish_sum)values('"+Request.Form["order_no"].ToString()+"','"+Request.Form["customer"].ToString()+"','" + Request.Form["department_no"].ToString()+ "','"+product_no.Text.ToString()+"','"+shipment_date.Text.ToString()+"','"+Request.Form["state2"].ToString()+"','"+Request.Form["remark"].ToString()+"','2','"+orderform_sum.Text.ToString()+"','"+accomplish_sum.Text.ToString()+"')";
myCommand.ExecuteNonQuery();

myCommand.Connection.Close();
Response.Write ("<script>window.alert('已成功添加,按“确定”返回');</script>");
Response.Write("<script language='javascript'>window.opener.location.href = window.opener.location.href;window.close();</script>");
}
}
newline2000 2006-09-20
  • 打赏
  • 举报
回复
服务器的配置问题,用户写权限未设置。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧