|
Abhishek Sur wrote: I thought everything that is not derived from ValueTypes are called ByRef.
But it isnt actually.
In .NET, parameters are passed by value by default. A reference type is passed as value but the value will be a reference. This is the reason why setting null is reflecting at the caller side. But you still can call Dispose() as it is just a method in the type.
|
|
|
|
|
I got your point budd.. Cool...
|
|
|
|
|
thanks all
thanks Abhishek Sur
i tested the example in c# and vb, this working.
i read more about byval to understand how the variable b receive the change the variable rr
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'prueba 1
Dim b As New SqlClient.SqlCommand()
Prueba1(b)
''here the variable b have commandtext="ddddddd", commandtimeout=45,
''CommandType = CommandType.StoredProcedure
b.CommandText = ""
'prueba 2
End Sub
Public Sub Prueba1(ByVal rr As SqlClient.SqlCommand)
rr.CommandText = "dddd"
rr.CommandTimeout = 45
rr.CommandType = CommandType.StoredProcedure
rr.Dispose()
rr = Nothing
End Sub
thanks
|
|
|
|
|
What is the point in adding parameters after calling ExecuteNonQuery ?
Next time,
1) Please format your code while posting. Use pre tags.
2) Stop posting email addresses. That is not how this forum works.
|
|
|
|
|
thank for all
thanks N a v a n e e t h
i understand all coment about byval o vbyref, first time i see the out parameter in c#.
the code original is and working, i tested.
public class PersonDataService
public void Person_Save(ref int personID, string nameFirst, string nameLast, DateTime dob)
{
SqlCommand cmd;
ExecuteNonQuery(out cmd, "Person_Save",
CreateParameter("@PersonID", SqlDbType.Int, personID, ParameterDirection.InputOutput),
CreateParameter("@NameFirst", SqlDbType.NVarChar, nameFirst),
CreateParameter("@NameLast", SqlDbType.NVarChar, nameLast),
CreateParameter("@DOB", SqlDbType.DateTime, dob));
personID = (int)cmd.Parameters["@PersonID"].Value;
cmd.Dispose();
}
and the class
protected void ExecuteNonQuery(string procName,
params IDataParameter[] procParams)
{
SqlCommand cmd;
ExecuteNonQuery(out cmd, procName, procParams);
}
protected void ExecuteNonQuery(out SqlCommand cmd, string procName,
params IDataParameter[] procParams)
{
SqlConnection cnx = null;
cmd = null;
try
{
cmd = new SqlCommand(procName);
cmd.CommandType = CommandType.StoredProcedure;
for (int index = 0; index < procParams.Length; index++)
{
cmd.Parameters.Add(procParams[index]);
}
if (_isOwner)
{
cnx = new SqlConnection(GetConnectionString());
cmd.Connection = cnx;
cnx.Open();
}
else
{
cmd.Connection = _txn.Connection;
cmd.Transaction = _txn;
}
cmd.ExecuteNonQuery();
}
catch
{
throw;
}
finally
{
if (_isOwner)
{
cnx.Dispose();
}
if (cmd != null) cmd.Dispose();
}
}
regards,
MS
|
|
|
|
|
i will translate to vb, but with ref parameter dont work
|
|
|
|
|
ByRef is similar to ref parameter...
|
|
|
|
|
I HAVE SOME QUESTIONS:
1-I am using a marquee tag on my website but it is from right to left. I want it goes from left to right. What should I do?
2-and first problem for menu. dynamic menu open to right. but I want that my sub menu appear on the left of menu. Please help me.
3- If I want to use many text for marquee tag what should I do?
for example on the first time that website refresh the marquee text is "A". if the page refresh the marquee tag changes to "B" and so forth.
excuse me for low english.
|
|
|
|
|
hasani2007 wrote: 1-I am using a marquee tag on my website but it is from right to left. I want it goes from left to right. What should I do?
use directionn=right
<marquee width="100%" behaviour="scroll" direction="right">
hasani2007 wrote: 2-and first problem for menu. dynamic menu open to right. but I want that my sub menu appear on the left of menu. Please help me.
Are you using any MenuControl to show menu?
Create the menu yourself using Javascript.. The best way to do this.
hasani2007 wrote: 3- If I want to use many text for marquee tag what should I do?
You need to make your own logic around this.. when to show what and based on that logic create the Response.
|
|
|
|
|
I am looking for a simple ASP newsletter app so our web users can sign up to review newsletters and other marketing material from us. If any body has any sample code of this and can point me in the right direction I would appreciate it.
Thanks
sk
|
|
|
|
|
Let me know what exactly the problem you are facing.
Logic is most simple, you need to maintain a database of all the subscribed users and send mails to them periodically.
|
|
|
|
|
The following code runs fine on my development computer but when I publish the website to the server it throws the error 'Object does not support this property or method'
var OLECMDID = 7;
var PROMPT = 1; // 2 DONTPROMPTUSER
var WebBrowser = '<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
If I debug it throught the browser the following line is where it has trouble:
WebBrowser1.ExecWB(OLECMDID, PROMPT);
How can I get this to run on the server?
|
|
|
|
|
Are you putting Windows WebBrowser control over a Web page. This is weird.
Why not you use IFrame to do this ??
|
|
|
|
|
Hi..
how can i load word document to iframe.. specially when the document is on my c:\assignment folder and not in the website root.
what will be the src value;
thanks
By:
Hemant Thaker
|
|
|
|
|
What do you mean?? Are you going to download the word file.
If you want to show the content of the Word File, it wont be possible. You need to read the word document using Word Interop services and then create HTML document based on it and then show the html content to the IFrame.
If you want to transmit the file just create an HTTPHandler and call the handler from the src and within the processRequest place a
Response.clear();
Response.TransmitFile(@"c:\assignment folder\yourfile.doc")
Response.close();
But in such a case the file will be downloaded from the IFrame.
|
|
|
|
|
Hi..
I get the path of this word document and just want to display it in iframe
privided that it's in c:\somefolder\xyz.doc
dont want to download it..
what will i set as src property of iframe... (the path)
thanks
By:
Hemant Thaker
|
|
|
|
|
|
Does it works in browsers other than IE. Actually this is an MHT solution... Only IE can open MHT i guess...
Other browsers might download the mht docoment ...
|
|
|
|
|
No idea. Let me read that one .
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Hi...
I just want to load .doc file into iframe...
this .doc file is not the part of my website,,, its not anywhere in root directory... but somewhere in c:\somedirectory\.....
(outside of my project)..
what should i put in "src" attribute of iframe.
i m accessing iframe from codebehind file.
iframe.attributes["src"] = "????????????????????";
thanks
By:
Hemant Thaker
|
|
|
|
|
No. You cant set src property of IFrame if the folder is not within a valid virtual path. To do this, you need to create a HttpHandler.
Say you write
<iframe src="WordResource.axd?id=xxx">
Now create a class WordResource and implement from IHttpHandler
in ProcessRequest method place
string id = context.Request.QueryString["id"];
context.Response.TransmitFile("yourfilepath");
Now place the definition of WordResource.axd in your web.config
|
|
|
|
|
Yes.. I have tested the Demo application. The solution is really of no use.
Its title should be "Creating your First Server Side Custom Control".
Even the Server side control just creates an IFrame and places the mht in its source. Thus it is shown in IE properly, but not in mozilla or other browser.
I think the only solution to this should be to read the entire word content from server and generate an equivalent HTML... with proper CSS and all.
|
|
|
|
|
hello all
i am using asp.net with crystal report in my project.
when i load report null is not null exception occured.
it works fine on my development machine ,testing server
but when i upload it to webserver it throws javasricpt exception
null cannot be null message box.
i have done lots of googling but i cannot find any
solution. Plz help me
|
|
|
|
|
When you are getting this error ?
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
This is the patent NullReference error that comes to the browser.
There might happen when a script is loaded which might be calling a control before actually its been rendered in the document.
Thus it is always recommended to place a script either in an event.. if not any control event, use document.onload or place it below body tag.
In your case, I think the html output is not rendered properly. Make sure that Crystal Report dlls are properly installed in the web server and has access to them.
|
|
|
|