DataTable already belongs to this DataSet.

swemohamed

New member
Joined
Feb 4, 2015
Messages
2
Programming Experience
Beginner
HTML:
what solution of this erorr
PHP:
Imports System.Data
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Frmallreports
    Dim cn As New SqlConnection
    Dim cmd As New SqlCommand
    Dim cmd1 As New SqlCommand
    Dim da As New SqlDataAdapter
    Dim das As New SqlDataAdapter
    Dim ds As New DataSet
    Dim ds2 As New DataSet
    Dim dt As New DataTable
    Dim dt2 As New DataTable
    Private Sub fillcom()
        Dim strSQL As String = "SELECT * FROM acad_qualific_info where Aqualific_no=2 "

        cmd1.CommandType = CommandType.Text
        cmd1.CommandText = strSQL
        cmd1.Connection = cn
        das.SelectCommand = cmd1
        das.Fill(ds, "acad_qualific_info")


        With ComboBox1
            .DataSource = ds.Tables("acad_qualific_info")
            .DisplayMember = "Spesification"
            .ValueMember = "aqualific_no"
            .SelectedIndex = 0
        End With
    End Sub
    Private Sub Frmallreports_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If cn.State = ConnectionState.Open Then cn.Close()
        cn.ConnectionString = "Data Source=mohamed-swe\sqlexpress;Initial Catalog=project;Integrated Security=True"
        cn.Open()
        fillcom()
        rep1()

    End Sub
    Private Sub rep1()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "acadmic"
        cmd.Connection = cn
       
        cmd.Parameters.AddWithValue("@Param2", ComboBox1.Text)
        da.SelectCommand = cmd
        ds2.Clear()
        dt2.Clear()
        dt2.TableName = "acadmic"

        ds2.Tables.Add(dt2)
        Try
            da.Fill(ds2.Tables("acadmic"))
        Catch ex As Exception

        End Try

        Dim rt As New CrystalReport15

        rt.SetDataSource(ds2.Tables("acadmic"))
        CrystalReportViewer1.ReportSource = rt
    End Sub


     Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As  System.Object, ByVal e As System.EventArgs) Handles  ComboBox1.SelectedIndexChanged
        rep1()
    End Sub
End Class
expert2.png
 
Hi,

Without getting into the specifics of your coding, if you get an error of any sort then the first thing to do is to check the documentation with regards to the methods you are using to see if those methods actually do what you are expecting. So knowing that have a look at this:-

https://msdn.microsoft.com/en-us/library/system.data.dataset.clear(v=vs.110).aspx

So what should you use to get rid of this error?:-

https://msdn.microsoft.com/en-us/li...aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

Hope that helps.

Cheers,

Ian
 

Latest posts

Back
Top