problem with dataset [modified]
-
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
-
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
-
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
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
-
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
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
-
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
Please post code with proper formatting.
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net
-
Please post code with proper formatting.
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net
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