473,326 Members | 2,680 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,326 software developers and data experts.

Why not need ref when dataAdapter.Fill

ad
Hi,

When we use
myDataAdapter.Fill(myDataTable)

The parameter myDataTable is call by reference.

Why there is no need to add ref before the paremeter?
Feb 7 '06 #1
3 1353
"MyDataTable" is a reference type. Variables that are reference types consist
of only the pointer to that data. So, when you pass a parameter that is a
reference type into a method, it acts (through the pointer) directly on the
object.
Credit for the quintessential example of clarity in writing on this
difficult subject goes to MVP Jon Skeet in his description here:

http://www.yoda.arachsys.com/csharp/parameters.html

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"ad" wrote:
Hi,

When we use
myDataAdapter.Fill(myDataTable)

The parameter myDataTable is call by reference.

Why there is no need to add ref before the paremeter?

Feb 7 '06 #2
DataTable is the reference type rather than value type thus the
reference is passed and no need to use ref. It is a compile error if
you add ref here.

Feb 7 '06 #3
ad <fl****@wfes.tcc.edu.tw> wrote:
When we use
myDataAdapter.Fill(myDataTable)

The parameter myDataTable is call by reference.

Why there is no need to add ref before the paremeter?


The parameter not passed *by* reference - that means something slightly
different. Instead, the reference (which is the value of the
myDataAdapter variable) is passed by value.

See the page Peter referred you to for more details.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 7 '06 #4

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

Similar topics

2
by: hch | last post by:
dataAdapter.Update(data, "TableName") won’t work! I was about to deploy my first website on the Internet only to discover that the dataAdapter.Update() throws the Server Error in the third...
3
by: Tee | last post by:
Hi, I need some help about filling dataset, I am not sure how to describe it, so I give the example here. da = new OleDbDataAdapter("SELECT * FROM Path WHERE PathID=1", cnn); ...
3
by: Shapper | last post by:
Hello, Until now I have been using Dreamweaver to create ASP.Net/VB web sites. I gave up of using it. Too many limitations. What is the best software to create ASP.NET/VB web sites? Maybe...
3
by: Stephen Noronha | last post by:
I have a question, please correct me if I am wrong. I am assuming that a dataadapter establishes a connection and after filling the dataset or datatable or whatever, will close the connection to...
2
by: Jason Huang | last post by:
Hi, I am wondering why use the DataTableMapping in SqlDataAdapter when Updating data. Would someone give me some advice? Thanks for help. Jason
2
by: susan.f.barrett | last post by:
Hi, Despite me being able to type the following in to SQL Server and it updating 1 row: > updatestockcategory 1093, 839 In my code, it is not updating any rows. dataSet = new DataSet();
3
by: Rich | last post by:
What is the diffeence bewtween a dataAdapter.InsertCommand and dataAdapter.SelectCommand (and dataAdapter.UpdateCommand for that matter)? Dim da As SqlDataAdapter conn.Open da.SelectCommand =...
0
by: mike1402 | last post by:
Hi ! I get the error below sometimes when retrieving a big amount of data using Datadapter.Fill(dataset,"table"). But when I send the command Fill again, there is no error. Is it a fault of...
2
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, I created a simple dll in VB2005 to use ADO.Net -- oleDBDataAdapter to write data to an Excel file. The code (below) works fine from an Excel file (invoke the dll from Excel to write to...
6
by: Tark Siala | last post by:
hi i'm using VS.NET 2005 +SP1 C#, and i connect access database by ADO.NET 2.0. i'm using Dataset to (insert,update,delete) and in get data i use (Datareader), but my problem when i do this: 1 -...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.