Click here to Skip to main content
15,040,003 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello. I need to get data into dataview (to loop through the rows in the dataview) from my dataset(after making some changing some records:insert, update, insert).
So i need an answer on these two questions:
Can i get data from dataadapter into dataview ? Or i have to get data from dataadapter into dataset then from dataset to dataview(If it's possible)

I have tried something like this:
Dim strconnection As String = "Data Source=EASMAR-PC;Initial Catalog=Database Connection;Integrated Security=True;"
        _cn = New SqlConnection(strconnection)
        cmd.Connection = _cn
        'Get the data from database into dataadapter
        _DataAdapter.SelectCommand = New SqlCommand("SELECT * FROM tblCustomer", _cn)
        'Fill the dataset from dataadapter
        Dim dt As New DataTable
        dt = _DataSet.Tables("tblCustomer")
        'dt contain nothing!!


And i am getting this error:
Object reference not set to an instance of an object.

On this line:
Pheonyx 3-Jan-14 6:00am
After "_DataAdapter.Fill(_DataSet)" how many tables are present in _DataSet.Tables ?
Sibasisjena 3-Jan-14 6:04am
There may be 2 cases
1.The table tblCustomer is not there in dataset
2.There is no table in the dataset

Please check the dataset while debugging and let me know.

Hi the following link may help you
[no name] 3-Jan-14 6:23am
Thank you :)
helpful link
Sibasisjena 3-Jan-14 6:31am
Please like my solution :)
I only have one table. I replaced the name of the table by its index. I don't think it's the problem.
Dim dt As New DataTable
dt = _DataSet.Tables(0)

But it worked.
now i'm getting my data from dataset.
I checked the dataset, it contains my table.
And the previous error is gone. I am going to continue my idea. Hope it works.
Thank you for your response.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900