Re: Can i pass a SqlConnection object with opened connection to a method/function as a parameter?
From: Parco (parco_at_nowlover.com)
Date: 10/02/04
- Next message: Jan Rizek: "news in Outlook Express"
- Previous message: Willy Denoyette [MVP]: "Re: Issue with ASP.NET client, COM Interop, and Identity impersonation"
- In reply to: Richard Blewett [DevelopMentor]: "Re: Can i pass a SqlConnection object with opened connection to a method/function as a parameter?"
- Next in thread: Richard Blewett [DevelopMentor]: "Re: Can i pass a SqlConnection object with opened connection to a method/function as a parameter?"
- Reply: Richard Blewett [DevelopMentor]: "Re: Can i pass a SqlConnection object with opened connection to a method/function as a parameter?"
- Reply: Nick Malik: "Re: Can i pass a SqlConnection object with opened connection to a method/function as a parameter?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 2 Oct 2004 18:13:47 +0800
This is my assembly object's method:
public static bool CheckPermission(SqlConnection objconn, string
permissionitem, string itemname, string loginuser)
{
SqlCommand objcmd = new SqlCommand("EXEC [checkpermission]
@permissionitem = '" + DataTools.EscapeMask(permissionitem) + "', @itemname
= '" + DataTools.EscapeMask(itemname) + "', @loginacc = '" +
DataTools.EscapeMask(GetLoginUser(loginuser, LoginAccount)) + "', @logincus
= '" + DataTools.EscapeMask(GetLoginUser(loginuser, LoginCustomer)) + "'",
(SqlConnection)objconn);
short intresult = (short)objcmd.ExecuteScalar();
bool checkresult;
if(intresult > 0)
{
checkresult = true;
}
else
{
checkresult = false;
}
objcmd.Dispose();
return checkresult;
}
This is my code of ASP.NET page which using the method:
SqlConnection objconn = new
SqlConnection(ConfigurationSettings.AppSettings["connstr_webhosting"]);
objconn.Open();
bool permited = (bool)CPanel.CheckPermission(objconn, "systeminfo",
"yes", User.Identity.Name);
How to solve it?
"Richard Blewett [DevelopMentor]" <richardb@develop.com> ¦b¶l¥ó
news:uiz4%23tFqEHA.2900@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g...
> This should be fine, can you show us the code of how you pass the
connection and what you do with it when you get it
>
> Regards
>
> Richard Blewett - DevelopMentor
> http://staff.develop.com/richardb/weblog
>
>
nntp://news.microsoft.com/microsoft.public.dotnet.framework/
>
> Can i pass a SqlConnection object with opened connection to a
> method/function as a parameter?
>
> For example, i need a method to process something from ASP.NET by a .NET
> assembly, but i don't want to connect a new connection anymore and just
use
> the existed opened sqlconnection object to do it and pass the object to
the
> method.
>
> that is a static method.
> but iis told me an exception error that is System.InvalidCastException
>
>
> why?
> and how to solved?
> or how to do it?
>
>
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004
>
>
>
> [microsoft.public.dotnet.framework]
Relevant Pages
... // Convert times to string ... public static bool errorHandler ... int intLeft, int intTop, ... // screenWidth and screenHeight). ...
(comp.programming)
... Function getConn(ByVal strDBName As String) As ... Dim strConn As String ... Dim objConn As System.Data.OleDb.OleDbConnection ... Fehler bei der Anmeldung für den Benutzer ''. ...
(microsoft.public.de.german.entwickler.dotnet.datenbank)
... methods in your long concatenated string, ... DataTools.EscapeMask method (a static method, apparently), or the ... > connection and what you do with it when you get it ... >> the existed opened sqlconnection object to do it and pass the object to ...
(microsoft.public.dotnet.framework)
... > private static extern IntPtr FindWindow(string className, ... > public static bool ShowStartIcon ... > SHFullScreenHelper.ShowSIPButton(Me, False) 'This hides the SIP button ... > lpClassName As String, ByVal lpWindowName As String) As IntPtr ...
(microsoft.public.dotnet.framework.compactframework)
... Dim objConn As Connection ... Dim objRS As Recordset ... Dim strSQL As String ...
(microsoft.public.access.macros)