Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. problem with dataset [modified]

problem with dataset [modified]

Scheduled Pinned Locked Moved ASP.NET
helpcomworkspace
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    govindi unal
    wrote on last edited by
    #1

    Protected Sub btStart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btStart.Click Session("NoOfRecords") = 0 Try sqlConn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("Constr") 'sqlConn.Open() With sqlComm .Connection = sqlConn .CommandText = "OLE_InsertExamDetails" .CommandType = CommandType.StoredProcedure .Parameters.Add("@RollNumber", SqlDbType.Char, 100).Value = Trim(txtrollnumber.Text) .Parameters.Add("@ExamDate", SqlDbType.DateTime).Value = "02-02-2009" .Parameters.Add("@SemesterName", SqlDbType.Char, 20).Value = "One" .Parameters.Add("@Papertype", SqlDbType.Char, 20).Value = RadioButtonList1.SelectedItem.Text End With sqlDataAdap.SelectCommand = sqlComm sqlConn.Open() 'sqlReader = sqlComm.ExecuteReader 'If sqlReader.Read Then ' While sqlReader.Read ' Response.Write("<br>") ' Response.Write(sqlReader(0)) ' End While 'End If sqlDataset = New DataSet sqlDataAdap.Fill(sqlDataset) Catch ex As Exception lblmessage.text = "Error while inserting" End Try sqlConn.Close() 'MsgBox(dt1.Rows.Count) MsgBox(sqlDataset.Tables.Count) MsgBox(sqlDataset.Tables(0).Rows.Count) ' FillDataSet(sqlDataset) 'display() End Sub this click event shows one table and no of records in the table but when i click on another command button on same aspx page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' MsgBox(dt1.TableName) MsgBox(sqlDataset.Tables.Count) MsgBox(sqlDataset.Tables(0).Rows.Count) End Sub this it returns 0 and error cannot find table 0

    modified on Monday, June 8, 2009 6:58 AM

    S A 2 Replies Last reply
    0
    • G govindi unal

      Protected Sub btStart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btStart.Click Session("NoOfRecords") = 0 Try sqlConn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("Constr") 'sqlConn.Open() With sqlComm .Connection = sqlConn .CommandText = "OLE_InsertExamDetails" .CommandType = CommandType.StoredProcedure .Parameters.Add("@RollNumber", SqlDbType.Char, 100).Value = Trim(txtrollnumber.Text) .Parameters.Add("@ExamDate", SqlDbType.DateTime).Value = "02-02-2009" .Parameters.Add("@SemesterName", SqlDbType.Char, 20).Value = "One" .Parameters.Add("@Papertype", SqlDbType.Char, 20).Value = RadioButtonList1.SelectedItem.Text End With sqlDataAdap.SelectCommand = sqlComm sqlConn.Open() 'sqlReader = sqlComm.ExecuteReader 'If sqlReader.Read Then ' While sqlReader.Read ' Response.Write("<br>") ' Response.Write(sqlReader(0)) ' End While 'End If sqlDataset = New DataSet sqlDataAdap.Fill(sqlDataset) Catch ex As Exception lblmessage.text = "Error while inserting" End Try sqlConn.Close() 'MsgBox(dt1.Rows.Count) MsgBox(sqlDataset.Tables.Count) MsgBox(sqlDataset.Tables(0).Rows.Count) ' FillDataSet(sqlDataset) 'display() End Sub this click event shows one table and no of records in the table but when i click on another command button on same aspx page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' MsgBox(dt1.TableName) MsgBox(sqlDataset.Tables.Count) MsgBox(sqlDataset.Tables(0).Rows.Count) End Sub this it returns 0 and error cannot find table 0

      modified on Monday, June 8, 2009 6:58 AM

      S Offline
      S Offline
      saanj
      wrote on last edited by
      #2

      On the click of another command button, other dataset might be re-initialized.

      Either you love IT or leave IT...

      1 Reply Last reply
      0
      • G govindi unal

        Protected Sub btStart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btStart.Click Session("NoOfRecords") = 0 Try sqlConn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("Constr") 'sqlConn.Open() With sqlComm .Connection = sqlConn .CommandText = "OLE_InsertExamDetails" .CommandType = CommandType.StoredProcedure .Parameters.Add("@RollNumber", SqlDbType.Char, 100).Value = Trim(txtrollnumber.Text) .Parameters.Add("@ExamDate", SqlDbType.DateTime).Value = "02-02-2009" .Parameters.Add("@SemesterName", SqlDbType.Char, 20).Value = "One" .Parameters.Add("@Papertype", SqlDbType.Char, 20).Value = RadioButtonList1.SelectedItem.Text End With sqlDataAdap.SelectCommand = sqlComm sqlConn.Open() 'sqlReader = sqlComm.ExecuteReader 'If sqlReader.Read Then ' While sqlReader.Read ' Response.Write("<br>") ' Response.Write(sqlReader(0)) ' End While 'End If sqlDataset = New DataSet sqlDataAdap.Fill(sqlDataset) Catch ex As Exception lblmessage.text = "Error while inserting" End Try sqlConn.Close() 'MsgBox(dt1.Rows.Count) MsgBox(sqlDataset.Tables.Count) MsgBox(sqlDataset.Tables(0).Rows.Count) ' FillDataSet(sqlDataset) 'display() End Sub this click event shows one table and no of records in the table but when i click on another command button on same aspx page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' MsgBox(dt1.TableName) MsgBox(sqlDataset.Tables.Count) MsgBox(sqlDataset.Tables(0).Rows.Count) End Sub this it returns 0 and error cannot find table 0

        modified on Monday, June 8, 2009 6:58 AM

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        govindi unal wrote:

        hv a code in click event of a command button in which i am filling a dataset the dataset shows tables and table rows but when i click on another command button same dataset returns zero table and zero rows

        Please put your code over here.

        cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net

        G 1 Reply Last reply
        0
        • A Abhijit Jana

          govindi unal wrote:

          hv a code in click event of a command button in which i am filling a dataset the dataset shows tables and table rows but when i click on another command button same dataset returns zero table and zero rows

          Please put your code over here.

          cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net

          G Offline
          G Offline
          govindi unal
          wrote on last edited by
          #4

          Protected Sub btStart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btStart.Click Session("NoOfRecords") = 0 Try sqlConn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("Constr") 'sqlConn.Open() With sqlComm .Connection = sqlConn .CommandText = "OLE_InsertExamDetails" .CommandType = CommandType.StoredProcedure .Parameters.Add("@RollNumber", SqlDbType.Char, 100).Value = Trim(txtrollnumber.Text) .Parameters.Add("@ExamDate", SqlDbType.DateTime).Value = "02-02-2009" .Parameters.Add("@SemesterName", SqlDbType.Char, 20).Value = "One" .Parameters.Add("@Papertype", SqlDbType.Char, 20).Value = RadioButtonList1.SelectedItem.Text End With sqlDataAdap.SelectCommand = sqlComm sqlConn.Open() 'sqlReader = sqlComm.ExecuteReader 'If sqlReader.Read Then ' While sqlReader.Read ' Response.Write("<br>") ' Response.Write(sqlReader(0)) ' End While 'End If sqlDataset = New DataSet sqlDataAdap.Fill(sqlDataset) Catch ex As Exception lblmessage.text = "Error while inserting" End Try sqlConn.Close() 'MsgBox(dt1.Rows.Count) MsgBox(sqlDataset.Tables.Count) MsgBox(sqlDataset.Tables(0).Rows.Count) ' FillDataSet(sqlDataset) 'display() End Sub this click event shows one table and no of records in the table but when i click on another command button on same aspx page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' MsgBox(dt1.TableName) MsgBox(sqlDataset.Tables.Count) MsgBox(sqlDataset.Tables(0).Rows.Count) End Sub this it returns 0 and error cannot find table 0

          A 1 Reply Last reply
          0
          • G govindi unal

            Protected Sub btStart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btStart.Click Session("NoOfRecords") = 0 Try sqlConn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("Constr") 'sqlConn.Open() With sqlComm .Connection = sqlConn .CommandText = "OLE_InsertExamDetails" .CommandType = CommandType.StoredProcedure .Parameters.Add("@RollNumber", SqlDbType.Char, 100).Value = Trim(txtrollnumber.Text) .Parameters.Add("@ExamDate", SqlDbType.DateTime).Value = "02-02-2009" .Parameters.Add("@SemesterName", SqlDbType.Char, 20).Value = "One" .Parameters.Add("@Papertype", SqlDbType.Char, 20).Value = RadioButtonList1.SelectedItem.Text End With sqlDataAdap.SelectCommand = sqlComm sqlConn.Open() 'sqlReader = sqlComm.ExecuteReader 'If sqlReader.Read Then ' While sqlReader.Read ' Response.Write("<br>") ' Response.Write(sqlReader(0)) ' End While 'End If sqlDataset = New DataSet sqlDataAdap.Fill(sqlDataset) Catch ex As Exception lblmessage.text = "Error while inserting" End Try sqlConn.Close() 'MsgBox(dt1.Rows.Count) MsgBox(sqlDataset.Tables.Count) MsgBox(sqlDataset.Tables(0).Rows.Count) ' FillDataSet(sqlDataset) 'display() End Sub this click event shows one table and no of records in the table but when i click on another command button on same aspx page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' MsgBox(dt1.TableName) MsgBox(sqlDataset.Tables.Count) MsgBox(sqlDataset.Tables(0).Rows.Count) End Sub this it returns 0 and error cannot find table 0

            A Offline
            A Offline
            Abhijit Jana
            wrote on last edited by
            #5

            Please post code with proper formatting.

            cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net

            G 1 Reply Last reply
            0
            • A Abhijit Jana

              Please post code with proper formatting.

              cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net

              G Offline
              G Offline
              govindi unal
              wrote on last edited by
              #6

              Protected Sub btStart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btStart.Click Session("NoOfRecords") = 0 Try sqlConn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("Constr") With sqlComm .Connection = sqlConn .CommandText = "OLE_InsertExamDetails" .CommandType = CommandType.StoredProcedure .Parameters.Add("@RollNumber", SqlDbType.Char, 100).Value = Trim(txtrollnumber.Text) .Parameters.Add("@ExamDate", SqlDbType.DateTime).Value = "02-02-2009" .Parameters.Add("@SemesterName", SqlDbType.Char, 20).Value = "One" .Parameters.Add("@Papertype", SqlDbType.Char, 20).Value = RadioButtonList1.SelectedItem.Text End With sqlDataAdap.SelectCommand = sqlComm sqlConn.Open() sqlDataset = New DataSet sqlDataAdap.Fill(sqlDataset) Catch ex As Exception lblmessage.text ="Error in inserting" End Try sqlConn.Close() MsgBox(sqlDataset.Tables.Count) MsgBox(sqlDataset.Tables(0).Rows.Count) End Sub it displays number of tables and corresponding records but when i click on another command button ] for number of tables it displays 0 and for number of rows it generates error cannot find table 0

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups