Click here to Skip to main content
15,888,270 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: APS.NET Pin
N a v a n e e t h23-Sep-09 15:29
N a v a n e e t h23-Sep-09 15:29 
GeneralRe: APS.NET Pin
Christian Graus23-Sep-09 17:14
protectorChristian Graus23-Sep-09 17:14 
GeneralRe: APS.NET Pin
Not Active24-Sep-09 1:02
mentorNot Active24-Sep-09 1:02 
AnswerRe: APS.NET Pin
Christian Graus23-Sep-09 15:28
protectorChristian Graus23-Sep-09 15:28 
Questiondata access Pin
raquidd2223-Sep-09 11:26
raquidd2223-Sep-09 11:26 
AnswerRe: data access Pin
Abhishek Sur23-Sep-09 12:17
professionalAbhishek Sur23-Sep-09 12:17 
GeneralRe: data access Pin
N a v a n e e t h23-Sep-09 15:47
N a v a n e e t h23-Sep-09 15:47 
GeneralRe: data access Pin
Abhishek Sur23-Sep-09 23:28
professionalAbhishek Sur23-Sep-09 23:28 
I dont know if you tried this in VB or not.

Initially this was my conception as well... I thought everything that is not derived from ValueTypes are called ByRef.
But it isnt actually.

If you call using ByVal, you can change any properties inside the object and it will reflect the caller, but it will not allow setting the actual object to Nothing or Dispose it. Only If you call using ByRef it allows this.

You may try out this :

Dim b As New SqlClient.SqlCommand()
x(b)
b.CommandText = "" ' this will allow Because of ByVal but will assign            ' value ddd to CommandText

Public Sub x(ByVal rr As SqlClient.SqlCommand)
        rr.CommandText = "dddd"
        rr.Dispose()
        rr = nothing
End Sub


You can try this.
Even this does happen in C#.
 private void button1_Click(object sender, EventArgs e)
 {
      SqlCommand cmd = new SqlCommand();
      this.x(ref cmd);
      cmd.CommandText = ""; // This will throw Error... 
           
 }

private void x(ref SqlCommand com)
{
     com = null;
}


Just removing the ref keyword will allow this ... OMG | :OMG:
Rose | [Rose] Rose | [Rose]

Abhishek Sur

My Latest Articles
Create CLR objects in SQL Server 2005
C# Uncommon Keywords
Read/Write Excel using OleDB

Don't forget to click "Good Answer" if you like to.

GeneralRe: data access Pin
N a v a n e e t h24-Sep-09 5:03
N a v a n e e t h24-Sep-09 5:03 
GeneralRe: data access Pin
Abhishek Sur25-Sep-09 12:16
professionalAbhishek Sur25-Sep-09 12:16 
GeneralRe: data access Pin
raquidd2230-Sep-09 6:27
raquidd2230-Sep-09 6:27 
AnswerRe: data access Pin
N a v a n e e t h23-Sep-09 15:44
N a v a n e e t h23-Sep-09 15:44 
GeneralRe: data access Pin
raquidd2224-Sep-09 6:38
raquidd2224-Sep-09 6:38 
GeneralRe: data access Pin
raquidd2224-Sep-09 7:06
raquidd2224-Sep-09 7:06 
GeneralRe: data access Pin
Abhishek Sur25-Sep-09 12:15
professionalAbhishek Sur25-Sep-09 12:15 
Questionquestions Pin
hasani200723-Sep-09 10:25
hasani200723-Sep-09 10:25 
AnswerRe: questions Pin
Abhishek Sur23-Sep-09 10:32
professionalAbhishek Sur23-Sep-09 10:32 
QuestionNewsletter App Pin
kruegersck23-Sep-09 10:07
kruegersck23-Sep-09 10:07 
AnswerRe: Newsletter App Pin
Abhishek Sur23-Sep-09 10:26
professionalAbhishek Sur23-Sep-09 10:26 
QuestionObject does not support this property or method Pin
dptalt23-Sep-09 8:04
dptalt23-Sep-09 8:04 
AnswerRe: Object does not support this property or method Pin
Abhishek Sur23-Sep-09 9:23
professionalAbhishek Sur23-Sep-09 9:23 
Questioniframe .. src Pin
Hemant Thaker23-Sep-09 4:45
Hemant Thaker23-Sep-09 4:45 
AnswerRe: iframe .. src Pin
Abhishek Sur23-Sep-09 5:47
professionalAbhishek Sur23-Sep-09 5:47 
QuestionRe: iframe .. src Pin
Hemant Thaker23-Sep-09 6:40
Hemant Thaker23-Sep-09 6:40 
AnswerRe: iframe .. src Pin
Abhijit Jana23-Sep-09 6:44
professionalAbhijit Jana23-Sep-09 6:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.