S
shiwei
Unregistered / Unconfirmed
GUEST, unregistred user!
在VB.NET+ASP.NET下 SQL数据库 要修改DataGrid控件的数据 运行下面的代码,出错信息如下: 在位置 0 处没有任何行。 说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.IndexOutOfRangeException: 在位置 0 处没有任何行。
用.NET Framework DataGrid不能分页 用DataSet 又不能修改数据
以下代码是(修改)页面的 请高手修改 谢谢!!!!
Imports System.Data.SqlClient
Private wxgzid As Integer
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
wxgzid = Convert.ToInt32(Request("id")
If Not Page.IsPostBack Then
Me.initialdata(wxgzid)
End If
End Sub
Sub initialdata(ByVal ID As Integer)
Dim conn As New SqlConnection
conn.ConnectionString = ConfigurationSettings.AppSettings("connectionstring"
Dim selectquery = "select ID,cDate,cName,cnumber,cprice,ctotal from wxgz where ID =" + ID.ToString()
Dim cmd As New SqlCommand(selectquery, conn)
Dim da As New SqlDataAdapter
da.SelectCommand = cmd
Dim result As New DataSet
da.Fill(result, "wxgz"
Me.TextBox1.Text = result.Tables(0).Rows(0)("cDate"
Me.TextBox2.Text = result.Tables(0).Rows(0)("cName"
Me.TextBox3.Text = result.Tables(0).Rows(0)("cNumber"
Me.TextBox4.Text = result.Tables(0).Rows(0)("cPrice"
Me.TextBox5.Text = result.Tables(0).Rows(0)("cTotal"
End Sub
异常详细信息: System.IndexOutOfRangeException: 在位置 0 处没有任何行。
用.NET Framework DataGrid不能分页 用DataSet 又不能修改数据
以下代码是(修改)页面的 请高手修改 谢谢!!!!
Imports System.Data.SqlClient
Private wxgzid As Integer
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
wxgzid = Convert.ToInt32(Request("id")
If Not Page.IsPostBack Then
Me.initialdata(wxgzid)
End If
End Sub
Sub initialdata(ByVal ID As Integer)
Dim conn As New SqlConnection
conn.ConnectionString = ConfigurationSettings.AppSettings("connectionstring"
Dim selectquery = "select ID,cDate,cName,cnumber,cprice,ctotal from wxgz where ID =" + ID.ToString()
Dim cmd As New SqlCommand(selectquery, conn)
Dim da As New SqlDataAdapter
da.SelectCommand = cmd
Dim result As New DataSet
da.Fill(result, "wxgz"
Me.TextBox1.Text = result.Tables(0).Rows(0)("cDate"
Me.TextBox2.Text = result.Tables(0).Rows(0)("cName"
Me.TextBox3.Text = result.Tables(0).Rows(0)("cNumber"
Me.TextBox4.Text = result.Tables(0).Rows(0)("cPrice"
Me.TextBox5.Text = result.Tables(0).Rows(0)("cTotal"
End Sub