|
Yep, got the wrong one
only two letters away from being an asset
|
|
|
|
|
There is no such thing as APS.NET. I get the impression you have no idea what you're doing. That doesn't make for a secure login system. Perhaps you should pay someone to do it for you. Be careful if you decide to list this job on places like rentacoder, because some people advertise on places like that, take jobs they can't do, and post here asking us to do it for them. We tend not to do work for people who are being paid and have no clue.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
hello
i find a great article about data access, it is to sql
i change the data access to work with sybase
i change the sql object by sybase object
Protected Overloads Sub ExecuteNonQuery(ByRef cmd As AseCommand, ByRef procName As String, ByVal ParamArray
procParams() As IDataParameter)
'Method variablesoutDim cmd As SqlCommand
Dim cnx As AseConnection = Nothing
cmd = Nothing
'Avoids "Use of unassigned variable" compiler error
Try
'Setup command object
cmd = New AseCommand(procName)
cmd.CommandType = CommandType.StoredProcedure
Dim index As Integer = 0
Do While (index < procParams.Length)
cmd.Parameters.Add(procParams(index))
index = (index + 1)
Loop
'Determine the transaction owner and process accordingly
If _esIniciante Then
cnx = New AseConnection(GetConnectionString)
cmd.Connection = cnx
cnx.Open()
Else
cmd.Connection = _txn.Connection
cmd.Transaction = _txn
End If
'Execute the command
cmd.ExecuteNonQuery()
Catch ex As Exception
Throw
Finally
If _esIniciante Then
cnx.Dispose()
End If
If (Not (cmd) Is Nothing) Then
cmd.Dispose()
End If
End Try
End Sub
when call the function ExecuteNonQuery
Public Function Cliente_obtenerPorCedula(ByRef clienteID As Integer, ByVal cedula As String) As DataSet
Dim cmd As AseCommand
ExecuteNonQuery(cmd, "crm_co_clientecedula", _
CreateParameter("@i_cliente_id", AseDbType.Integer, clienteID, ParameterDirection.Output), _
CreateParameter("@i_cedula", AseDbType.NVarChar, cedula))
clienteID = CType(cmd.Parameters("@i_cliente_id").Value, Integer)
cmd.Dispose()
End Function
everything runs fine until invoke the code cmd.Parameters("@i_cliente_id").Value
ocurr the exception --> Run-time exception thrown : System.ObjectDisposedException - Cannot access a disposed object.
Object name: 'AseCommand: '.
the dispose cause exception
Catch ex As Exception
Throw
Finally
If _esIniciante Then
cnx.Dispose()
End If
If (Not (cmd) Is Nothing) Then
cmd.Dispose()
End If
End Try
the cmd.dispose -->System.ObjectDisposedException - Cannot access a disposed object.
the cnx.dispose -->Parameters {"Cannot access a disposed object.Object name: 'AseCommand: '.
while i comment this line, the code work
'If _esIniciante Then
' cnx.Dispose()
'End If
'If (Not (cmd) Is Nothing) Then
' cmd.Dispose()
'End If
where can be the problem ?
the original code is c# and sql that's work fine
me email is raquidd@yahoo.com
regards
sorry for me english
|
|
|
|
|
when you call
ExecuteNonQuery(cmd, "crm_co_clientecedula", _
CreateParameter("@i_cliente_id", AseDbType.Integer, clienteID, ParameterDirection.Output), _
CreateParameter("@i_cedula", AseDbType.NVarChar, cedula))
It will dispose cmd as it is ByRef. So cmd.Parameters will fail. Properties of Disposed object is inaccessible.
|
|
|
|
|
Abhishek Sur wrote: It will dispose cmd as it is ByRef.
This is not because it is passed as ByRef . It will get disposed even you pass as ByVal .
|
|
|
|
|
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 = "";
}
private void x(ref SqlCommand com)
{
com = null;
}
Just removing the ref keyword will allow this ...
|
|
|
|
|
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.
|
|
|
|