帮助:更新ASP.NET中的问题 [英] Help: Updating Problem in ASP.NET

查看:59
本文介绍了帮助:更新ASP.NET中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我的网页上有大约15个文本框,我从sql数据库中获取数据并将它们加载到各自的文本框中。


但是当我从数据库显示数据后更改文本框的值并单击按钮更新值时,更新查询工作正常但不存储新的输入值。同样,它只按以前的方式存储数据库中提取的数据。


我的代码中没有错误... 100%正确,我有信心,因为我已经执行了我的编码设置断点和逐行执行。


请帮我编辑数据并在数据库中更新...


谢谢提前....

Hi,

I have around 15 textbox in my webpage and i have fetched the datas form sql database and loaded them in their respective textboxes.

But when i change the values of the textbox after the data has been displayed from the database and click the button to update the values, the update query is working fine but not storing the newly entered values. Again it stores only the fetched datas from the database as in a previous manner.

No errors in my code...100% correct and i am confident because i have executed my codings by setting breakpoints and line by line execution.

Please help me to edit the datas and update it in the database...

Thanks in advance....

推荐答案

让我们看看100%正确的代码。仅发布从文本框中获取值的部分并在数据库中更新它们。
Let''s see the 100% correct code then. Post only the parts that gets the values from the textboxes and updates them in the database.


您好,


page_load 事件我有以下编码:


cmd =新的SqlCommand("选择ntitle,pubdate,pduration,ddnotice,dtnotice,emd,dav tdoc,ddtdoc,dttdoc,authcontact, prjcost,qual,otherd et,termscond from notice where nid =''"& txtNid.Text&"''",cn)

dr = cmd.ExecuteReader

如果dr.Read那么

txtNtitle.Text = dr.GetValue(0)

txtPD.Text = dr.GetValue(1)

txtPduration.Text = dr.GetValue(2)

txtDDN.Text = dr.GetValue(3)

txtDTN.Text = dr.GetValue(4)

txtEMD.Text = dr.GetValue(5)

txtDATD.Text = dr.GetValue(6)

txtDDTD.Text = dr.GetValue(7)

txtDTTD.Text = dr.GetValue(8)

txtAC.Text = dr.GetValue(9)

txtPcost.Text = dr.GetValue(10)

txtQD.Text = dr.GetValue(11)

txtOD.Text = dr.GetValue(12)

txtTC.Text = dr.GetValue(13)

结束如果

结束如果

dr.Close( )


通过检索文本框的所有必要值,上述编码很有效。加载页面后,如果需要,我将通过删除提取的值在文本框中输入新数据,然后单击按钮更新新输入的值。该按钮的编码如下:


cmd =新的SqlCommand(更新通知集ntitle =''"& txtNtitle.Text&"'',pubby =''"& txtPB.Text&"'',pubdate =''"& txtPD.Text&"'',pduration =''"& txtPduration.Text&" '',ddnotice =''"& txtDDN.Text&"'',dtnotice =''"& txtDTN.Text&"'',emd ="& Val(txtEMD.Text )&",davtdoc =''"& txtDATD.Text&"'',ddtdoc =''"& txtDDTD.Text&"'',dttdoc =''"& txtDTTD.Text&"'',authcontact =''"& txtAC.Text&"'',qual =''"& txtQD.Text&"'',otherdet ='' & txtOD.Text&"'',termscond =''"& txtTC.Text&"''where nid =''"& txtNid.Text&"''" ;,cn)


cmd.ExecuteNonQuery()


此编码工作正常......但他们没有更新我新输入的值。他们只更新从数据库中提取的先前值。


请帮助我....
Hi,

In page_load event i have the following codings:

cmd = New SqlCommand("Select ntitle,pubdate,pduration,ddnotice,dtnotice,emd,dav tdoc,ddtdoc,dttdoc,authcontact,prjcost,qual,otherd et,termscond from notice where nid=''" & txtNid.Text & "''", cn)
dr = cmd.ExecuteReader
If dr.Read Then
txtNtitle.Text = dr.GetValue(0)
txtPD.Text = dr.GetValue(1)
txtPduration.Text = dr.GetValue(2)
txtDDN.Text = dr.GetValue(3)
txtDTN.Text = dr.GetValue(4)
txtEMD.Text = dr.GetValue(5)
txtDATD.Text = dr.GetValue(6)
txtDDTD.Text = dr.GetValue(7)
txtDTTD.Text = dr.GetValue(8)
txtAC.Text = dr.GetValue(9)
txtPcost.Text = dr.GetValue(10)
txtQD.Text = dr.GetValue(11)
txtOD.Text = dr.GetValue(12)
txtTC.Text = dr.GetValue(13)
End If
End If
dr.Close()

The above coding works well by retrieving all the necessary values for the textbox. After the page has been loaded, I will enter new data in the textboxes by erasing the fetched values if needed and then click the button to update the newly entered values. The coding for the button is as follows:

cmd = New SqlCommand("Update notice set ntitle=''" & txtNtitle.Text & "'',pubby=''" & txtPB.Text & "'',pubdate=''" & txtPD.Text & "'',pduration=''" & txtPduration.Text & "'',ddnotice=''" & txtDDN.Text & "'',dtnotice=''" & txtDTN.Text & "'',emd=" & Val(txtEMD.Text) & ",davtdoc=''" & txtDATD.Text & "'',ddtdoc=''" & txtDDTD.Text & "'',dttdoc=''" & txtDTTD.Text & "'',authcontact=''" & txtAC.Text & "'',qual=''" & txtQD.Text & "'',otherdet=''" & txtOD.Text & "'',termscond=''" & txtTC.Text & "'' where nid=''" & txtNid.Text & "''", cn)

cmd.ExecuteNonQuery()

This codings work fine... But they are not updating my newly entered values. They are updating only previous values fetched from the database.

Please help me....


几个问题......
您是否也在更改txtNid文本框中的值?

nid列的数据类型是什么?
Couple of questions ...
Are you changing the value in the txtNid Textbox as well?
What is the data type of the nid column?


这篇关于帮助:更新ASP.NET中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆