473,378 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Dataset and DataAdapter - Hardcoded

Hi

I have the following hardcoded the following (only the relevant code is
shown),
to populate a datagrid. The data loads into the grid as expected

private void LoadData()
{
//THIS CODE WORKS FINE - within this eventhandler
and the dataset and dataadapter are availible in the intellisense

// Dataset dsModify = New Dataset();

// SqlDataAdapter daModify = new SqlDataAdapter();

}
private void btnModify_Click(object sender, System.EventArgs e)
{
//Accept user changes

// PROBLEM - the dsModify and daModify are not availible in intellisense
to allow modifications to be pushed through to the database

// Errors generated are :

1) The type or namespace daModify could not be found
are you missing a using directive or an assembly reference"
2) The name dsModify does not exist in the <class>.<form>
}
I have attempted to put the following code into the public class of the form

private System.Data.SqlClient.SqlDataAdapter daModify

and get an error saying that daModify is never used - however it is used in
LoadData()

Any assistance would be appreciated

Thanks

Christopher

Nov 16 '05 #1
2 4226
Christopher <Ch*********@discussions.microsoft.com> wrote:
I have the following hardcoded the following (only the relevant code is
shown),
to populate a datagrid. The data loads into the grid as expected

private void LoadData()
{
//THIS CODE WORKS FINE - within this eventhandler
and the dataset and dataadapter are availible in the intellisense

// Dataset dsModify = New Dataset();

// SqlDataAdapter daModify = new SqlDataAdapter();
}
private void btnModify_Click(object sender, System.EventArgs e)
{
//Accept user changes

// PROBLEM - the dsModify and daModify are not availible in intellisense
to allow modifications to be pushed through to the database

// Errors generated are :

1) The type or namespace daModify could not be found
are you missing a using directive or an assembly reference"
2) The name dsModify does not exist in the <class>.<form>
}

I have attempted to put the following code into the public class of the form

private System.Data.SqlClient.SqlDataAdapter daModify

and get an error saying that daModify is never used - however it is used in
LoadData()


Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
You need to change this line
//SqlDataAdapter daModify = new SqlDataAdapter();
to
this.daModify = new SqlDataAdapter();

and also you need to add this line to the class declaration
private System.Data.Dataset dsModify;

and change this line
//DataSet dsModify = new Dataset ();
to
this.dsModify = new Dataset();

--
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
"Christopher" <Ch*********@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
Hi

I have the following hardcoded the following (only the relevant code is
shown),
to populate a datagrid. The data loads into the grid as expected

private void LoadData()
{
//THIS CODE WORKS FINE - within this eventhandler
and the dataset and dataadapter are availible in the intellisense

// Dataset dsModify = New Dataset();

// SqlDataAdapter daModify = new SqlDataAdapter();

}
private void btnModify_Click(object sender, System.EventArgs e)
{
//Accept user changes

// PROBLEM - the dsModify and daModify are not availible in intellisense
to allow modifications to be pushed through to the database

// Errors generated are :

1) The type or namespace daModify could not be found
are you missing a using directive or an assembly reference"
2) The name dsModify does not exist in the <class>.<form>
}
I have attempted to put the following code into the public class of the form
private System.Data.SqlClient.SqlDataAdapter daModify

and get an error saying that daModify is never used - however it is used in LoadData()

Any assistance would be appreciated

Thanks

Christopher

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mojtaba Faridzad | last post by:
Hi, Please check these lines: DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet, "mytable"); DataRow row; row = dataSet.Tables.Rows; row.BeginEdit(); row = "555";
3
by: JacksonYin | last post by:
1. I can fill data from Excel to DataSet like this: OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../../Book1.xls;Extended Properties=Excel...
15
by: JIM.H. | last post by:
Hello, Can I send a dataset as a parameter into stored procedure and import data to a table in the stored procedure? Thanks, Jim.
4
by: Dave Taylor | last post by:
I've been using the dataset designer in Visual Studio to create typed datasets for my application by dragging over tables from the Server Explorer and dropping them into the designer. The problem...
12
by: Graham Blandford | last post by:
Hi all, Would someone be able to tell me the most 'graceful' way of removing unwanted rows from a dataset based on a condition prior to update? OR, resetting the rows all to unchanged after they...
12
by: chreo | last post by:
I GIVE UP...I can't refresh datagrid (dataset) I have datagrid = dgrPaczki Datasource of that datagrid = DataSetPaczki1.PACZKI_PAKOWALNIA (forgive me Polish words) Dataadapter which fills my...
4
by: Robert Bravery | last post by:
Hi All, I'm New to VS.net. Trying to figure out this new dataset thingy. Ok so I add a dataadapter with all the correct properties for a table. Then generate the dataset. Now open the dataset and...
0
by: davefromalbury | last post by:
I have a gridview connected to a objectdatasource. Can't for the life of me get it to display anything though, always appears empty. The dataset always seems to be filled with records, as the...
7
by: David P. Donahue | last post by:
My experience with databases using C# has been pretty limited thus far. Mostly I just use a SELECT statement to populate a DataSet, which is just read-only (mostly for display on a web page), or...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.