Showing posts with label public. Show all posts
Showing posts with label public. Show all posts

Wednesday, March 21, 2012

Passing a Dataset from a function in a class

Hi, I have a class called Jobs. In that class is the function below..

Public Function GetJobTitle(ByVal Job_Title_ID As Integer, ByVal Company_ID
As Integer) As DataSet
' Setup the Stored Procedure
Dim SqlCommand As New SqlCommand
Dim SqlConnection As New SqlConnection(DataLayer.ConnectionString)
Try
SqlCommand.CommandText = "dbo.DeleteJobTitle"
SqlCommand.CommandType = System.Data.CommandType.StoredProcedure
SqlCommand.Connection = SqlConnection
' Load the Parameters
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@dotnet.itags.org.Job_Title_ID",
System.Data.SqlDbType.Int, 4)).Value = Job_Title_ID
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@dotnet.itags.org.Company_ID", System.Data.SqlDbType.Int,
4)).Value = Company_ID
' Fire the Procedure
SqlConnection.Open()
' Create a dataset
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = SqlCommand
Dim ds As New DataSet
da.Fill(ds, "JobTitle")
Return ds
Catch ex As Exception
Throw New Exception(ex.ToString)
Finally
SqlConnection.Close()
End Try
End Function

I now have a web form called Default.aspx

How can I poplulate a Datagrid or Select box from the above function?

Datagrid1.Datasource = jobs.GetJobTitle(1,1) ?

Please help

Thanks Daren"Daren Hawes" <newsgroups@.webdesignmagic.com.au> wrote in
news:uOXyu5cVFHA.1452@.TK2MSFTNGP14.phx.gbl:

> I now have a web form called Default.aspx
> How can I poplulate a Datagrid or Select box from the above function?
> Datagrid1.Datasource = jobs.GetJobTitle(1,1) ?

Yes exactly - but just remember to call Datagrid1.databind.

--
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Passing a Dataset from a function in a class

Hi, I have a class called Jobs. In that class is the function below..
Public Function GetJobTitle(ByVal Job_Title_ID As Integer, ByVal Company_ID
As Integer) As DataSet
' Setup the Stored Procedure
Dim SqlCommand As New SqlCommand
Dim SqlConnection As New SqlConnection(DataLayer.ConnectionString)
Try
SqlCommand.CommandText = "dbo.DeleteJobTitle"
SqlCommand.CommandType = System.Data.CommandType.StoredProcedure
SqlCommand.Connection = SqlConnection
' Load the Parameters
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@dotnet.itags.org.Job_Title_ID",
System.Data.SqlDbType.Int, 4)).Value = Job_Title_ID
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@dotnet.itags.org.Company_ID", System.Data.SqlDbType.Int,
4)).Value = Company_ID
' Fire the Procedure
SqlConnection.Open()
' Create a dataset
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = SqlCommand
Dim ds As New DataSet
da.Fill(ds, "JobTitle")
Return ds
Catch ex As Exception
Throw New Exception(ex.ToString)
Finally
SqlConnection.Close()
End Try
End Function
I now have a web form called Default.aspx
How can I poplulate a Datagrid or Select box from the above function?
Datagrid1.Datasource = jobs.GetJobTitle(1,1) ?
Please help
Thanks Daren"Daren Hawes" <newsgroups@.webdesignmagic.com.au> wrote in
news:uOXyu5cVFHA.1452@.TK2MSFTNGP14.phx.gbl:

> I now have a web form called Default.aspx
> How can I poplulate a Datagrid or Select box from the above function?
> Datagrid1.Datasource = jobs.GetJobTitle(1,1) ?
Yes exactly - but just remember to call Datagrid1.databind.
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
[url]http://members.ebay.com/aboutme/spot18/[/url]

Passing a page to a public class

Hi guys

I'm trying to implement an external class (.cs) for popping a window and
doing various bits and peices. I want to pass to the overloaded constructor a
reference to the page that called the class, so that the class can add some
javascript to the page.

Here's my globals and constructor...

public string e;
public System.Web.UI.Page _sender;

public ACR(string e, System.Web.UI.Page sender)
{
_errorcode = e;
_sender = sender;

DoACR();
}

here's the code for the DoACR() function...

public void DoACR()
{
string cs;
cs = "<script language=\"Javascript\">\n";
cs += "window.open('acr.aspx?c=" + _errorcode + "&p=" +
_sender.Request.ServerVariables["HTTP_URL"].ToString() + "', '_blank',
'width=" +
ConfigurationSettings.AppSettings.Get("System_ReportBug_WindowWidth") + ",
height=" +
ConfigurationSettings.AppSettings.Get("System_ReportBug_WindowHeight") +
",channelmode=0,directories=0,fullscreen=0,location =0,resizable=0,scrollbars=0,status=0,toolbar=0');";
cs += "window.close();\n";
cs += "</script>";
if(!_sender.IsStartupScriptRegistered("close"))
_sender.RegisterStartupScript("close", cs);
}

and from my Page_Load of my page, I'm calling it thus...

ACR crash = new ACR("0x00", this);

I'm getting a "object reference not set to an object" error on the line in
DoACR() that calls _server.Request.ServerVariables["HTTP_URL"].ToString();

How is that happening? As I'm callling my class from Page_Load, I assume
that "this" has been defined as the Page?

Any thoughts appreciated...

Cheers

Danyour problem is here:

_server.Request.ServerVariable*s["HTTP_URL"].ToString()

dump the ".ToString()"

it is a "string" already

cs += "blah" + _server.Request.ServerVariable*s["HTTP_URL"] +
"moreblah";

will work just fine

you owe me a mars bar :-)
Cheers John - I do indeed owe you a Mars bar! In fact, you can have a King
Size Mars bar if you can tell me why ServerVariables["HTTP_URL"] is
empty......!

:o)

"John Rivers" wrote:

> your problem is here:
> _server.Request.ServerVariable*s["HTTP_URL"].ToString()
> dump the ".ToString()"
> it is a "string" already
> cs += "blah" + _server.Request.ServerVariable*s["HTTP_URL"] +
> "moreblah";
> will work just fine
> you owe me a mars bar :-)
>
No matter, sorted that one! :o)

"dhnriverside" wrote:

> Cheers John - I do indeed owe you a Mars bar! In fact, you can have a King
> Size Mars bar if you can tell me why ServerVariables["HTTP_URL"] is
> empty......!
> :o)
> "John Rivers" wrote:
> > your problem is here:
> > _server.Request.ServerVariable*s["HTTP_URL"].ToString()
> > dump the ".ToString()"
> > it is a "string" already
> > cs += "blah" + _server.Request.ServerVariable*s["HTTP_URL"] +
> > "moreblah";
> > will work just fine
> > you owe me a mars bar :-)

Passing a page to a public class

Hi guys
I'm trying to implement an external class (.cs) for popping a window and
doing various bits and peices. I want to pass to the overloaded constructor
a
reference to the page that called the class, so that the class can add some
javascript to the page.
Here's my globals and constructor...
public string e;
public System.Web.UI.Page _sender;
public ACR(string e, System.Web.UI.Page sender)
{
_errorcode = e;
_sender = sender;
DoACR();
}
here's the code for the DoACR() function...
public void DoACR()
{
string cs;
cs = "<script language=\"Javascript\">\n";
cs += "window.open('acr.aspx?c=" + _errorcode + "&p=" +
_sender.Request.ServerVariables["HTTP_URL"].ToString() + "', '_blank',
'width=" +
ConfigurationSettings.AppSettings.Get("System_ReportBug_WindowWidth") + ",
height=" +
ConfigurationSettings.AppSettings.Get("System_ReportBug_WindowHeight") +
" ,channelmode=0,directories=0,fullscreen=
0,location=0,resizable=0,scrollbars
=0,status=0,toolbar=0');";
cs += "window.close();\n";
cs += "</script>";
if(!_sender.IsStartupScriptRegistered("close"))
_sender.RegisterStartupScript("close", cs);
}
and from my Page_Load of my page, I'm calling it thus...
ACR crash = new ACR("0x00", this);
I'm getting a "object reference not set to an object" error on the line in
DoACR() that calls _server.Request.ServerVariables["HTTP_URL"].ToString();
How is that happening? As I'm callling my class from Page_Load, I assume
that "this" has been defined as the Page?
Any thoughts appreciated...
Cheers
Danyour problem is here:
_server.Request.ServerVariable=ADs["HTTP_URL"].ToString()
dump the ".ToString()"
it is a "string" already
cs +=3D "blah" + _server.Request.ServerVariable=ADs["HTTP_URL"] +
"moreblah";
will work just fine
you owe me a mars bar :-)
Cheers John - I do indeed owe you a Mars bar! In fact, you can have a King
Size Mars bar if you can tell me why ServerVariables["HTTP_URL"] is
empty......!
:o)
"John Rivers" wrote:

> your problem is here:
> _server.Request.ServerVariable_s["HTTP_URL"].ToString()
> dump the ".ToString()"
> it is a "string" already
> cs += "blah" + _server.Request.ServerVariable_s["HTTP_URL"] +
> "moreblah";
> will work just fine
> you owe me a mars bar :-)
>
No matter, sorted that one! :o)
"dhnriverside" wrote:
> Cheers John - I do indeed owe you a Mars bar! In fact, you can have a King
> Size Mars bar if you can tell me why ServerVariables["HTTP_URL"] is
> empty......!
> :o)
> "John Rivers" wrote:
>