This message was discovered on ASPFriends.com 'aspngvb' list.
|
-- Moved from [aspngfreeforall] to [aspngvb] by Tim Musschoot <Click here to reveal e-mail address> --
Hi All , How to Create Context Object in ASP.NET ? In VB 6.0 , We are using COM+ Service Type Library (COMSVCS.DLL) . I have to use getcontext object in DLL. So kindly suggest me How to get create context in VB.net
shatdal
-----Original Message----- From: Ambati Srinivasalu [mailto:Click here to reveal e-mail address] Sent: Monday, May 20, 2002 7:17 PM To: aspngfreeforall Subject: [aspngfreeforall] Passing Null Value to a method in a class
Hi,
How can I pass a "null" as a param to a method in a class which is expecting a string or integer ?
Here is the sample code below
Thanks in advance
Srinivas
//************************ WEB APPLICATION *******************************
public void LinkButtonInsert_Click(object src, EventArgs e) { try { dbCustomer objCustomer = new dbCustomer(); if (objCustomer.Insert_Customer(1, System.DBNull.Value)) { LabelMessage.Text = "New Customer Inserted."; } else { LabelMessage.Text = "New Customer Insert Failed."; } showSearch(); } catch (Exception Err) { //display error message LabelMessage.Text = String.Concat(LabelMessage.Text, "showSearch: ", Err.Message, "<br>"); } }
//************************ DATA ACCESS CLASS *******************************
using System; using System.Security.Principal; using System.Runtime.InteropServices; using System.Data; using System.Data.SqlClient; using System.Xml; using System.IO; using System.IO.IsolatedStorage;
namespace DemoApplication { /// <summary> /// Data Access Layer for Tbl_Customer. /// </summary> public class dbCustomer { public dbCustomer() { // // TODO: Add constructor logic here // }
public bool Insert_Customer (int CustomerID , string CustomerName )
SqlConnection dbConnection = new SqlConnection("server=<DatabaseServer>;uid=<userid>;pwd=<password>;database= <databaseName>"); SqlCommand Cmd = new SqlCommand("sp_Insert_Customer", dbConnection); Cmd.CommandType = CommandType.StoredProcedure;
SqlParameter pCustomerID = new SqlParameter("@CustomerID", SqlDbType.Int, 4); SqlParameter pCustomerName = new SqlParameter("@CustomerName", SqlDbType.VarChar, 255);
pCustomerID.Value = CustomerID; pCustomerName.Value = CustomerName;
Cmd.Parameters.Add(pCustomerID); Cmd.Parameters.Add(pCustomerName);
try { dbConnection.Open(); Cmd.ExecuteNonQuery(); dbConnection.Close(); if (Convert.ToBoolean(pStatus.Value)) { return true; } else { return false; } } catch { return false; } }
} }
//************************ STORED PROCEDURE *******************************
CREATE PROCEDURE .sp_Insert_Customer( @CustomerID int , @CustomerName varchar(500) = NULL ) AS
INSERT INTO Tbl_Customer( CustomerID, CustomerName ) VALUES ( @CustomerID, @CustomerName )
GO
| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com = NEWSGROUP
|
|
| |
| |
| Wally McClure |
You will want to import the System.EnterpriseServices namespace. From there you can use either AutoComplete or ContextUtil for the .SetComplete() or .SetAbort() operations.
Wally
McClure Development 865-693-3004 118 Durwood Rd. Knoxville, TN 37922 http://www.mccluredevelopment.com/ Building Scalable Applications with the Microsoft.NET Framework http://www/scalabilitywith.net/ "Building Highly Scalable Database Applications with Microsoft.NET" http://www.amazon.com/exec/obidos/ASIN/0764536400/qid=1020081583/sr=8-1/refsr_8_1_1/104-9726427-8447111
-----Original Message----- From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address] Sent: Monday, May 20, 2002 10:42 AM To: aspngvb Subject: [aspngvb] Create Context
-- Moved from [aspngfreeforall] to [aspngvb] by Tim Musschoot <Click here to reveal e-mail address> --
Hi All , How to Create Context Object in ASP.NET ? In VB 6.0 , We are using COM+ Service Type Library (COMSVCS.DLL) . I have to use getcontext object in DLL. So kindly suggest me How to get create context in VB.net
shatdal
-----Original Message----- From: Ambati Srinivasalu [mailto:Click here to reveal e-mail address] Sent: Monday, May 20, 2002 7:17 PM To: aspngfreeforall Subject: [aspngfreeforall] Passing Null Value to a method in a class
Hi,
How can I pass a "null" as a param to a method in a class which is expecting a string or integer ?
Here is the sample code below
Thanks in advance
Srinivas
//************************ WEB APPLICATION *******************************
public void LinkButtonInsert_Click(object src, EventArgs e) { try { dbCustomer objCustomer = new dbCustomer(); if (objCustomer.Insert_Customer(1, System.DBNull.Value)) { LabelMessage.Text = "New Customer Inserted."; } else { LabelMessage.Text = "New Customer Insert Failed."; } showSearch(); } catch (Exception Err) { //display error message LabelMessage.Text String.Concat(LabelMessage.Text, "showSearch: ", Err.Message, "<br>"); } }
//************************ DATA ACCESS CLASS *******************************
using System; using System.Security.Principal; using System.Runtime.InteropServices; using System.Data; using System.Data.SqlClient; using System.Xml; using System.IO; using System.IO.IsolatedStorage;
namespace DemoApplication { /// <summary> /// Data Access Layer for Tbl_Customer. /// </summary> public class dbCustomer { public dbCustomer() { // // TODO: Add constructor logic here // }
public bool Insert_Customer (int CustomerID , string CustomerName )
SqlConnection dbConnection = new SqlConnection("server=<DatabaseServer>;uid=<userid>;pwd=<password>;database<databaseName>"); SqlCommand Cmd = new SqlCommand("sp_Insert_Customer", dbConnection); Cmd.CommandType = CommandType.StoredProcedure;
SqlParameter pCustomerID = new SqlParameter("@CustomerID", SqlDbType.Int, 4); SqlParameter pCustomerName = new SqlParameter("@CustomerName", SqlDbType.VarChar, 255);
pCustomerID.Value = CustomerID; pCustomerName.Value = CustomerName;
Cmd.Parameters.Add(pCustomerID); Cmd.Parameters.Add(pCustomerName);
try { dbConnection.Open(); Cmd.ExecuteNonQuery(); dbConnection.Close(); if (Convert.ToBoolean(pStatus.Value)) { return true; } else { return false; } } catch { return false; } }
} }
//************************ STORED PROCEDURE *******************************
CREATE PROCEDURE .sp_Insert_Customer( @CustomerID int , @CustomerName varchar(500) = NULL ) AS
INSERT INTO Tbl_Customer( CustomerID, CustomerName ) VALUES ( @CustomerID, @CustomerName )
GO
| ASP.net DOCS = http://www.aspng.com/docs | [aspngfreeforall] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/aspngfreeforall = JOIN/QUIT | news://ls.asplists.com = NEWSGROUP
| [aspngvb] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT
|
|
| |
|
|
|
|
|