amillyard
asked on
c# / Executing a Stored Procedure from an asp.net page to update a SQL 2005 Table
HI there,
c# / Executing a Stored Procedure from an asp.net page.
the asp.net form page is as follows:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CreateNewLeadS ourceProvi der.aspx.c s" Inherits="FORTUNE.LeadSour ceProvider s.CreateNe wLeadSourc eProvider" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button_CreateNewLeadSource Provider_C lick(objec t sender, EventArgs e)
{
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>F.O.R.T.U.N.E. - Lead Source Providers</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<span style="font-family: Arial"><strong><span style="font-size: 14pt">Create a New Lead Source Provider<br />
<br />
<br />
</span></strong>
Step 1 :: Define New Lead Source Provider Profile<br />
<br />
<br />
</span>
<asp:Label ID="Label_LeadSourceProvid erName" runat="server" Font-Names="Arial" Font-Size="Small"
Height="20px" Text="Lead Source Provider Name" Width="200px"></asp:Label> <span style="font-family: Arial">
</span>
<asp:TextBox ID="TextBox_LeadSourceProv iderName" runat="server" Font-Names="Arial"
Font-Size="Small" Width="200px" MaxLength="50"></asp:TextB ox><span style="font-family: Arial"><br />
<br />
</span>
<asp:Label ID="Label_CompanyRegistere dName" runat="server" Font-Names="Arial" Font-Size="Small"
Height="20px" Text="Company Registered Name" Width="200px"></asp:Label> <span style="font-family: Arial">
</span>
<asp:TextBox ID="TextBox_CompanyRegiste redName" runat="server" Font-Names="Arial"
Font-Size="Small" Width="200px" MaxLength="50"></asp:TextB ox><span style="font-family: Arial"><br />
<asp:Label ID="Label_CompanyRegistrat ionNumber" runat="server" Font-Names="Arial"
Font-Size="Small" Height="20px" Text="Company Registration Number" Width="200px"></asp:Label> <span
style="font-family: Arial"> </span>
<asp:TextBox ID="TextBox_CompanyRegistr ationNumbe r" runat="server" Font-Names="Arial"
Font-Size="Small" MaxLength="50"></asp:TextB ox><br />
<span style="font-family: Arial">
<br />
<asp:Label ID="Label1" runat="server" Font-Names="Arial" Font-Size="Small" Height="20px"
Text="VAT Registered" Width="200px"></asp:Label> <span style="font-family: Arial">
<asp:RadioButton ID="RadioButton_Yes" runat="server" Font-Names="Arial" Font-Size="Small"
GroupName="RadioButton_Val ueAddTaxRe gistration Ref" Text="Yes" /> <span style="font-size: 10pt"></span>
<asp:RadioButton ID="RadioButton_No" runat="server" Checked="True" Font-Names="Arial"
Font-Size="Small" GroupName="RadioButton_Val ueAddTaxRe gistration Ref" Text="No" /></span><br />
<asp:Label ID="Label_ValueAddTaxRegis tration" runat="server" Font-Names="Arial" Font-Size="Small"
Height="20px" Text="VAT Registration Number" Width="200px"></asp:Label> <span style="font-family: Arial">
</span>
<asp:TextBox ID="TextBox_ValueAddTaxReg istration" runat="server" Font-Names="Arial"
Font-Size="Small" MaxLength="50"></asp:TextB ox><span style="font-family: Arial"><br />
</span>
<br />
<asp:Label ID="Label_Switchboard" runat="server" Font-Names="Arial" Font-Size="Small"
Height="20px" Text="Switchboard" Width="200px"></asp:Label> <span style="font-family: Arial">
</span>
<asp:TextBox ID="TextBox_Switchboard" runat="server" Font-Names="Arial" Font-Size="Small" MaxLength="50"></asp:TextB ox><br />
<asp:Label ID="Label_LandlineFax" runat="server" Font-Names="Arial" Font-Size="Small"
Height="20px" Text="Landline Fax" Width="200px"></asp:Label> <span style="font-family: Arial">
</span>
<asp:TextBox ID="TextBox_LandlineFax" runat="server" Font-Names="Arial" Font-Size="Small" MaxLength="50"></asp:TextB ox><span
style="font-family: Arial"><br />
</span>
<br />
<asp:Label ID="Label_WebsiteURL" runat="server" Font-Names="Arial" Font-Size="Small"
Height="20px" Text="Website URL" Width="200px"></asp:Label> <span style="font-family: Arial">
</span>
<asp:TextBox ID="TextBox_WebsiteURL" runat="server" Font-Names="Arial" Font-Size="Small" Width="200px" MaxLength="50"></asp:TextB ox><br />
<asp:Label ID="Label_EmailAddress" runat="server" Font-Names="Arial" Font-Size="Small"
Height="20px" Text="Email Address" Width="200px"></asp:Label>
<asp:TextBox ID="TextBox_EmailAddress" runat="server" Font-Names="Arial" Font-Size="Small" Width="200px" MaxLength="50"></asp:TextB ox><br />
<br />
</span>
<asp:Label ID="Label_ComplianceConfir med" runat="server" Font-Names="Arial" Font-Size="Small"
Height="20px" Text="Compliance Confirmed" Width="200px"></asp:Label> <asp:Check Box
ID="CheckBox_ComplianceCon firmed" runat="server" Font-Names="Arial" Font-Size="Small" /><br />
<br />
<br />
</span>
<asp:Button ID="Button_CreateNewLeadSo urceProvid er" runat="server" Text="Create New Lead Source Provider"
Width="235px" OnClick="Button_CreateNewL eadSourceP rovider_Cl ick" />
<asp:Label ID="Label_SubmissionStatus " runat="server" Font-Size="8pt" ForeColor="Red"></asp:Labe l><br />
<br />
<br />
<span style="font-size: 10pt; font-family: Arial"><strong>Step 1 - Define New Lead Source
Provider Profile</strong><br />
Step 2 -
<asp:HyperLink ID="HyperLink_CreateAddres s" runat="server" NavigateUrl="~/LeadSourceP roviders/C reateNewLe adSourcePr oviderAddr ess.aspx"> Create Address</asp:HyperLink><br />
Step 3 -
<asp:HyperLink ID="HyperLink_CreateContac t" runat="server" NavigateUrl="~/LeadSourceP roviders/C reateNewLe adSourcePr oviderCont act.aspx"> Create Contact</asp:HyperLink><br />
Step 4 -
<asp:HyperLink ID="HyperLink_CreateProduc t" runat="server" NavigateUrl="~/LeadSourceP roviders/C reateNewLe adSourcePr oviderProd uct.aspx"> Create Product</asp:HyperLink></s pan></div>
</form>
</body>
</html>
the Stored Procedure as follows:
ALTER PROCEDURE BackOffice.InsertNewLeadSo urceProvid er
@LeadSourceProviderName nvarchar(50),
@CompanyRegisteredName nvarchar(50),
@CompanyRegistrationNumber nvarchar(50),
@ValueAddTaxRegistered bit,
@ValueAddTaxRegistrationRe f nvarchar(50),
@Switchboard nvarchar(50),
@LandlineFax nvarchar(50),
@WebsiteURL nvarchar(50),
@EmailAddress nvarchar(50),
@ComplianceConfirmed bit
AS
BEGIN
INSERT LeadSourceProviders (LeadSourceProviderName,
CompanyRegisteredName, CompanyRegistrationNumber, ValueAddTaxRegistered, ValueAddTaxRegistrationRef ,
Switchboard,
LandlineFax,
WebsiteURL,
EmailAddress,
ComplianceConfirmed)
VALUES (@LeadSourceProviderName,
@CompanyRegisteredName,
@CompanyRegistrationNumber ,
@ValueAddTaxRegistered,
@ValueAddTaxRegistrationRe f,
@Switchboard,
@LandlineFax,
@WebsiteURL,
@EmailAddress,
@ComplianceConfirmed)
END
the asp.net form .cs code (i.e. code activated from button submit) as follows:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls. WebParts;
using System.Web.UI.HtmlControls ;
namespace FORTUNE.LeadSourceProvider s
{
public partial class CreateNewLeadSourceProvide r : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button_CreateNewLeadSource Provider_C lick(objec t sender, EventArgs e)
{
SqlDataSource FORTUNESQLDataSource = new SqlDataSource();
Label_SubmissionStatus.Tex t = null;
FORTUNESQLDataSource.Conne ctionStrin g = ConfigurationManager.Conne ctionStrin gs["FORTUN EConnectio nString"]. ToString() ;
FORTUNESQLDataSource.Inser tCommandTy pe = SqlDataSourceCommandType.S toredProce dure;
FORTUNESQLDataSource.Inser tCommand = "BackOffice.InsertNewLeadS ourceProvi der";
FORTUNESQLDataSource.Inser tParameter s.Add("@Le adSourcePr oviderName ", "Test 1");
FORTUNESQLDataSource.Inser tParameter s.Add("@Co mpanyRegis teredName" , "Test 1");
FORTUNESQLDataSource.Inser tParameter s.Add("@Co mpanyRegis trationNum ber", "1234567890");
FORTUNESQLDataSource.Inser tParameter s.Add("@Va lueAddTaxR egistered" , "TRUE");
FORTUNESQLDataSource.Inser tParameter s.Add("@Va lueAddTaxR egistratio nRef", "1234567890");
FORTUNESQLDataSource.Inser tParameter s.Add("@Sw itchboard" , "1234");
FORTUNESQLDataSource.Inser tParameter s.Add("@La ndlineFax" , "1234");
FORTUNESQLDataSource.Inser tParameter s.Add("@We bsiteURL", "test.com");
FORTUNESQLDataSource.Inser tParameter s.Add("@Em ailAddress ", "post@test.com");
FORTUNESQLDataSource.Inser tParameter s.Add("@Co mplianceCo nfirmed", "TRUE");
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ LeadSource ProviderNa me", TextBox_LeadSourceProvider Name.Text) ;
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ CompanyReg isteredNam e", TextBox_CompanyRegisteredN ame.Text);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ CompanyReg istrationN umber", TextBox_CompanyRegistratio nNumber.Te xt);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ ValueAddTa xRegistere d", TextBox_ValueAddTaxRegiste red.Bit);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ ValueAddTa xRegistrat ionRef", TextBox_ValueAddTaxRegistr ationRef.T ext);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ Switchboar d", TextBox_Switchboard.Text);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ LandlineFa x", TextBox_LandlineFax.Text);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ WebsiteURL ", TextBox_WebsiteURL.Text);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ EmailAddre ss", TextBox_EmailAddress.Text) ;
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ Compliance Confirmed" , TextBox_ComplianceConfirme d.Bit);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("A ctiveMembe rStatus", CheckBox_ActiveMemberStatu s.Text);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("D ateTimeSta mp", DateTime.Now.ToString());
//FORTUNESQLDataSource.Ins ertParamet ers.Add("D ataEntryUs er", "ADMIN");
//FORTUNESQLDataSource.Ins ertParamet ers.Add("U niqueSessi onID", Session.SessionID);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("U serIPAddre ss", Request.UserHostAddress.To String());
int RowsAffected = 0;
try
{
RowsAffected = FORTUNESQLDataSource.Inser t();
}
catch (Exception)
{
SQL_FailureHandler();
}
finally
{
Label_SubmissionStatus.Tex t = "[ Comitted to Database OK ]";
FORTUNESQLDataSource = null;
}
TextBox_LeadSourceProvider Name.Text = null;
TextBox_CompanyRegisteredN ame.Text = null;
TextBox_CompanyRegistratio nNumber.Te xt = null;
TextBox_ValueAddTaxRegistr ation.Text = null;
TextBox_SwitchboardNumber. Text = null;
TextBox_LandlineFax.Text = null;
TextBox_WebsiteURL.Text = null;
TextBox_EmailAddress.Text = null;
//CheckBox_ActiveMemberSta tus.Text = "FALSE";
}
private void SQL_FailureHandler()
{
// TODO SQL Failure Handler needs to be scripted
Label_SubmissionStatus.Tex t = "[ Commit to Database FAILURE ]";
}
}
}
The SQL 2005 database table has the same variables names and variable types as described in the Stored Procedure, and all set to allowing 'null' entries for the time being. The only two extra columns in the database table are: LeadSourceProvider_ID, int (auto increment) and DateTimeStamp (getDate()) -- bot set to non-null entry status.
the commented out code (on the form c# scripting portion) are the actual field values I would like to pass -- but have 'hard coded' the values in the meantime, trying to isolate where the error is.
The above scripts provide the data entry form ok, the Stored Procedure works fine when executed directly via SQL server (when adding manually the default values when submitting via SQL Server).
The problem is .... that when submitting the form button, the Stored Procedure does not appear to be activated correctly (or passing variable across etc) -- the effect is that nothing is updated to the database table accordingly.
Hopefully I have diligent enough with providing enough supporting evidence to work with.
Your time and efforts with this request for assistance is much apprieated.
Kind regards,
-andrew.
c# / Executing a Stored Procedure from an asp.net page.
the asp.net form page is as follows:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CreateNewLeadS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button_CreateNewLeadSource
{
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>F.O.R.T.U.N.E. - Lead Source Providers</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<span style="font-family: Arial"><strong><span style="font-size: 14pt">Create a New Lead Source Provider<br />
<br />
<br />
</span></strong>
Step 1 :: Define New Lead Source Provider Profile<br />
<br />
<br />
</span>
<asp:Label ID="Label_LeadSourceProvid
Height="20px" Text="Lead Source Provider Name" Width="200px"></asp:Label>
</span>
<asp:TextBox ID="TextBox_LeadSourceProv
Font-Size="Small" Width="200px" MaxLength="50"></asp:TextB
<br />
</span>
<asp:Label ID="Label_CompanyRegistere
Height="20px" Text="Company Registered Name" Width="200px"></asp:Label>
</span>
<asp:TextBox ID="TextBox_CompanyRegiste
Font-Size="Small" Width="200px" MaxLength="50"></asp:TextB
<asp:Label ID="Label_CompanyRegistrat
Font-Size="Small" Height="20px" Text="Company Registration Number" Width="200px"></asp:Label>
style="font-family: Arial"> </span>
<asp:TextBox ID="TextBox_CompanyRegistr
Font-Size="Small" MaxLength="50"></asp:TextB
<span style="font-family: Arial">
<br />
<asp:Label ID="Label1" runat="server" Font-Names="Arial" Font-Size="Small" Height="20px"
Text="VAT Registered" Width="200px"></asp:Label>
<asp:RadioButton ID="RadioButton_Yes" runat="server" Font-Names="Arial" Font-Size="Small"
GroupName="RadioButton_Val
<asp:RadioButton ID="RadioButton_No" runat="server" Checked="True" Font-Names="Arial"
Font-Size="Small" GroupName="RadioButton_Val
<asp:Label ID="Label_ValueAddTaxRegis
Height="20px" Text="VAT Registration Number" Width="200px"></asp:Label>
</span>
<asp:TextBox ID="TextBox_ValueAddTaxReg
Font-Size="Small" MaxLength="50"></asp:TextB
</span>
<br />
<asp:Label ID="Label_Switchboard" runat="server" Font-Names="Arial" Font-Size="Small"
Height="20px" Text="Switchboard" Width="200px"></asp:Label>
</span>
<asp:TextBox ID="TextBox_Switchboard" runat="server" Font-Names="Arial" Font-Size="Small" MaxLength="50"></asp:TextB
<asp:Label ID="Label_LandlineFax" runat="server" Font-Names="Arial" Font-Size="Small"
Height="20px" Text="Landline Fax" Width="200px"></asp:Label>
</span>
<asp:TextBox ID="TextBox_LandlineFax" runat="server" Font-Names="Arial" Font-Size="Small" MaxLength="50"></asp:TextB
style="font-family: Arial"><br />
</span>
<br />
<asp:Label ID="Label_WebsiteURL" runat="server" Font-Names="Arial" Font-Size="Small"
Height="20px" Text="Website URL" Width="200px"></asp:Label>
</span>
<asp:TextBox ID="TextBox_WebsiteURL" runat="server" Font-Names="Arial" Font-Size="Small" Width="200px" MaxLength="50"></asp:TextB
<asp:Label ID="Label_EmailAddress" runat="server" Font-Names="Arial" Font-Size="Small"
Height="20px" Text="Email Address" Width="200px"></asp:Label>
<asp:TextBox ID="TextBox_EmailAddress" runat="server" Font-Names="Arial" Font-Size="Small" Width="200px" MaxLength="50"></asp:TextB
<br />
</span>
<asp:Label ID="Label_ComplianceConfir
Height="20px" Text="Compliance Confirmed" Width="200px"></asp:Label>
ID="CheckBox_ComplianceCon
<br />
<br />
</span>
<asp:Button ID="Button_CreateNewLeadSo
Width="235px" OnClick="Button_CreateNewL
<asp:Label ID="Label_SubmissionStatus
<br />
<br />
<span style="font-size: 10pt; font-family: Arial"><strong>Step 1 - Define New Lead Source
Provider Profile</strong><br />
Step 2 -
<asp:HyperLink ID="HyperLink_CreateAddres
Step 3 -
<asp:HyperLink ID="HyperLink_CreateContac
Step 4 -
<asp:HyperLink ID="HyperLink_CreateProduc
</form>
</body>
</html>
the Stored Procedure as follows:
ALTER PROCEDURE BackOffice.InsertNewLeadSo
@LeadSourceProviderName nvarchar(50),
@CompanyRegisteredName nvarchar(50),
@CompanyRegistrationNumber
@ValueAddTaxRegistered bit,
@ValueAddTaxRegistrationRe
@Switchboard nvarchar(50),
@LandlineFax nvarchar(50),
@WebsiteURL nvarchar(50),
@EmailAddress nvarchar(50),
@ComplianceConfirmed bit
AS
BEGIN
INSERT LeadSourceProviders (LeadSourceProviderName,
CompanyRegisteredName, CompanyRegistrationNumber,
Switchboard,
LandlineFax,
WebsiteURL,
EmailAddress,
ComplianceConfirmed)
VALUES (@LeadSourceProviderName,
@CompanyRegisteredName,
@CompanyRegistrationNumber
@ValueAddTaxRegistered,
@ValueAddTaxRegistrationRe
@Switchboard,
@LandlineFax,
@WebsiteURL,
@EmailAddress,
@ComplianceConfirmed)
END
the asp.net form .cs code (i.e. code activated from button submit) as follows:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.
using System.Web.UI.HtmlControls
namespace FORTUNE.LeadSourceProvider
{
public partial class CreateNewLeadSourceProvide
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button_CreateNewLeadSource
{
SqlDataSource FORTUNESQLDataSource = new SqlDataSource();
Label_SubmissionStatus.Tex
FORTUNESQLDataSource.Conne
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
int RowsAffected = 0;
try
{
RowsAffected = FORTUNESQLDataSource.Inser
}
catch (Exception)
{
SQL_FailureHandler();
}
finally
{
Label_SubmissionStatus.Tex
FORTUNESQLDataSource = null;
}
TextBox_LeadSourceProvider
TextBox_CompanyRegisteredN
TextBox_CompanyRegistratio
TextBox_ValueAddTaxRegistr
TextBox_SwitchboardNumber.
TextBox_LandlineFax.Text = null;
TextBox_WebsiteURL.Text = null;
TextBox_EmailAddress.Text = null;
//CheckBox_ActiveMemberSta
}
private void SQL_FailureHandler()
{
// TODO SQL Failure Handler needs to be scripted
Label_SubmissionStatus.Tex
}
}
}
The SQL 2005 database table has the same variables names and variable types as described in the Stored Procedure, and all set to allowing 'null' entries for the time being. The only two extra columns in the database table are: LeadSourceProvider_ID, int (auto increment) and DateTimeStamp (getDate()) -- bot set to non-null entry status.
the commented out code (on the form c# scripting portion) are the actual field values I would like to pass -- but have 'hard coded' the values in the meantime, trying to isolate where the error is.
The above scripts provide the data entry form ok, the Stored Procedure works fine when executed directly via SQL server (when adding manually the default values when submitting via SQL Server).
The problem is .... that when submitting the form button, the Stored Procedure does not appear to be activated correctly (or passing variable across etc) -- the effect is that nothing is updated to the database table accordingly.
Hopefully I have diligent enough with providing enough supporting evidence to work with.
Your time and efforts with this request for assistance is much apprieated.
Kind regards,
-andrew.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK -- you are referring to the following method:
protected void Button_CreateNewLeadSource Provider_C lick(objec t sender, EventArgs e)
{
SqlDataSource FORTUNESQLDataSource = new SqlDataSource();
Label_SubmissionStatus.Tex t = null;
FORTUNESQLDataSource.Conne ctionStrin g = ConfigurationManager.Conne ctionStrin gs["FORTUN EConnectio nString"]. ToString() ;
FORTUNESQLDataSource.Inser tCommandTy pe = SqlDataSourceCommandType.S toredProce dure;
FORTUNESQLDataSource.Inser tCommand = "BackOffice.InsertNewLeadS ourceProvi der";
FORTUNESQLDataSource.Inser tParameter s.Add("@Le adSourcePr oviderName ", "Test 1");
FORTUNESQLDataSource.Inser tParameter s.Add("@Co mpanyRegis teredName" , "Test 1");
FORTUNESQLDataSource.Inser tParameter s.Add("@Co mpanyRegis trationNum ber", "1234567890");
FORTUNESQLDataSource.Inser tParameter s.Add("@Va lueAddTaxR egistered" , "TRUE");
FORTUNESQLDataSource.Inser tParameter s.Add("@Va lueAddTaxR egistratio nRef", "1234567890");
FORTUNESQLDataSource.Inser tParameter s.Add("@Sw itchboard" , "1234");
FORTUNESQLDataSource.Inser tParameter s.Add("@La ndlineFax" , "1234");
FORTUNESQLDataSource.Inser tParameter s.Add("@We bsiteURL", "test.com");
FORTUNESQLDataSource.Inser tParameter s.Add("@Em ailAddress ", "post@test.com");
FORTUNESQLDataSource.Inser tParameter s.Add("@Co mplianceCo nfirmed", "TRUE");
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ LeadSource ProviderNa me", TextBox_LeadSourceProvider Name.Text) ;
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ CompanyReg isteredNam e", TextBox_CompanyRegisteredN ame.Text);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ CompanyReg istrationN umber", TextBox_CompanyRegistratio nNumber.Te xt);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ ValueAddTa xRegistere d", TextBox_ValueAddTaxRegiste red.Bit);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ ValueAddTa xRegistrat ionRef", TextBox_ValueAddTaxRegistr ationRef.T ext);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ Switchboar d", TextBox_Switchboard.Text);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ LandlineFa x", TextBox_LandlineFax.Text);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ WebsiteURL ", TextBox_WebsiteURL.Text);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ EmailAddre ss", TextBox_EmailAddress.Text) ;
//FORTUNESQLDataSource.Ins ertParamet ers.Add("@ Compliance Confirmed" , TextBox_ComplianceConfirme d.Bit);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("A ctiveMembe rStatus", CheckBox_ActiveMemberStatu s.Text);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("D ateTimeSta mp", DateTime.Now.ToString());
//FORTUNESQLDataSource.Ins ertParamet ers.Add("D ataEntryUs er", "ADMIN");
//FORTUNESQLDataSource.Ins ertParamet ers.Add("U niqueSessi onID", Session.SessionID);
//FORTUNESQLDataSource.Ins ertParamet ers.Add("U serIPAddre ss", Request.UserHostAddress.To String());
int RowsAffected = 0;
try
{
RowsAffected = FORTUNESQLDataSource.Inser t();
}
catch (Exception)
{
SQL_FailureHandler();
}
finally
{
Label_SubmissionStatus.Tex t = "[ Comitted to Database OK ]";
FORTUNESQLDataSource = null;
}
TextBox_LeadSourceProvider Name.Text = null;
TextBox_CompanyRegisteredN ame.Text = null;
TextBox_CompanyRegistratio nNumber.Te xt = null;
TextBox_ValueAddTaxRegistr ation.Text = null;
TextBox_SwitchboardNumber. Text = null;
TextBox_LandlineFax.Text = null;
TextBox_WebsiteURL.Text = null;
TextBox_EmailAddress.Text = null;
//CheckBox_ActiveMemberSta tus.Text = "FALSE";
}
asking if I can debug locally -- i.e. via the Studio environment (step through) ? assuming this is so -- am in the process of doing that now.
-andrew.
protected void Button_CreateNewLeadSource
{
SqlDataSource FORTUNESQLDataSource = new SqlDataSource();
Label_SubmissionStatus.Tex
FORTUNESQLDataSource.Conne
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
//FORTUNESQLDataSource.Ins
int RowsAffected = 0;
try
{
RowsAffected = FORTUNESQLDataSource.Inser
}
catch (Exception)
{
SQL_FailureHandler();
}
finally
{
Label_SubmissionStatus.Tex
FORTUNESQLDataSource = null;
}
TextBox_LeadSourceProvider
TextBox_CompanyRegisteredN
TextBox_CompanyRegistratio
TextBox_ValueAddTaxRegistr
TextBox_SwitchboardNumber.
TextBox_LandlineFax.Text = null;
TextBox_WebsiteURL.Text = null;
TextBox_EmailAddress.Text = null;
//CheckBox_ActiveMemberSta
}
asking if I can debug locally -- i.e. via the Studio environment (step through) ? assuming this is so -- am in the process of doing that now.
-andrew.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tried to start the debug -- eventually the following Studio error message as follows:
Unable to start debugging on the web server. The format of the specified network name is invalid.
-andrew.
Unable to start debugging on the web server. The format of the specified network name is invalid.
-andrew.
ASKER
mmm...interesting...
when I double-clicked on the submit button as indicated -- there is another script now added into the .aspx form page (i.e. not where the original button click prodcedure sits in the .cs file) as follows:
<script runat="server">
protected void Button_CreateNewLeadSource Provider_C lick(objec t sender, EventArgs e)
{
}
</script>
-andrew.
when I double-clicked on the submit button as indicated -- there is another script now added into the .aspx form page (i.e. not where the original button click prodcedure sits in the .cs file) as follows:
<script runat="server">
protected void Button_CreateNewLeadSource
{
}
</script>
-andrew.
Do you have the Visual Studio's Project open locally on your machine?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
as a result, when clicking the submit button via the form .aspx page, obviously nothing is now firing up (as an empty container) ... yet the other .cs code (button submit) is still available as code.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
confirming that Visual Studio is open locally (desktop) -- connecting to web server / sql server remotely
ASKER
confirming the @page header as follows: (the .cs file name is exactly the same as indicated below)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CreateNewLeadS ourceProvi der.aspx.c s" Inherits="FORTUNE.LeadSour ceProvider s.CreateNe wLeadSourc eProvider" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button_CreateNewLeadSource Provider_C lick(objec t sender, EventArgs e)
{
}
</script>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CreateNewLeadS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button_CreateNewLeadSource
{
}
</script>
ASKER
Removed the string as requested.
"Go to the Designer of the application and in the properties toolbox, with the button selected, check the Events associated to the button. Delete the stting "Button_CreateNewLeadSourc eProvider_ Click" in the Click cell. Once deleted refresh the view and double click the button. Move your code to inside this new event handler."
Also, removed the previously inserted auto script in the .aspx and .cs page (as by double-clicking we are creating a new instance of the procedure).
Then saved .aspx page, refreshed (close pages and reopened .aspx). Double-clicked on the submit button, and again the procedure as above is inserted into the .aspx page.
"Go to the Designer of the application and in the properties toolbox, with the button selected, check the Events associated to the button. Delete the stting "Button_CreateNewLeadSourc
Also, removed the previously inserted auto script in the .aspx and .cs page (as by double-clicking we are creating a new instance of the procedure).
Then saved .aspx page, refreshed (close pages and reopened .aspx). Double-clicked on the submit button, and again the procedure as above is inserted into the .aspx page.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
just checking this double-clicking on submit button and inserting empty procedure container into .cs automatically -- is affecting on all other .aspx pages as well at the moment. so, its consistent across the project.
is there a global setting that has been changed perhaps inadvertantly?
is there a global setting that has been changed perhaps inadvertantly?
Are they code-behind pages in the same directory as the aspx pages on the web server? If you website is not published but instead the pages and are just copied to the web server directory, the .cs files need to be there as well.
ASKER
Changed the button script as requested above.
The following build error message with that .aspx page as follows:
'ASP.leadsourceproviders_c reatenewle adsourcepr ovider_asp x' does not contain a definition for MyButtonClickHandler
The following build error message with that .aspx page as follows:
'ASP.leadsourceproviders_c
ASKER
Checking on the @page error log -- the following message is also appearing:
Warning 1
Attribute 'Codebehind' in the @ Page directive is no longer supported. Convert this page to the new code-behind model by opening the Web site (project) containing the page in Visual Web Developer.
-- not sure how to change this? is this what's affecting the @page issue perhaps?
Warning 1
Attribute 'Codebehind' in the @ Page directive is no longer supported. Convert this page to the new code-behind model by opening the Web site (project) containing the page in Visual Web Developer.
-- not sure how to change this? is this what's affecting the @page issue perhaps?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Which version of .NET are you using, did you recently upgrade? In your @Page directive try changing "CodeBehind" to "CodeFile" as the @Page directive attributes have changed, this if of course if you have a new version of the .net framework.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes...success ! ... created a new .aspx form page, added a button, double-clicked and the procedure container appeared in the .cs file fine (as normally would expect).
not sure why this .cs association seems to have just broken itself on the existing files..but, putting that to one-side, will rebuild the .apsx page in question (as a fresh page) and make sure the advise above is adhered too to confirm all is well (i.e. answer original question!, as we got a little side tracked) -- do apprieate your attentiveness to this enquiry.
Obviously, I am looking to see if the error message will arise again (when processing the stored procedure) -- when trying to debug earlier, was when the .cs linking seem to got disturbed etc.
Is it possible to debud remotely? (as failed earlier)
not sure why this .cs association seems to have just broken itself on the existing files..but, putting that to one-side, will rebuild the .apsx page in question (as a fresh page) and make sure the advise above is adhered too to confirm all is well (i.e. answer original question!, as we got a little side tracked) -- do apprieate your attentiveness to this enquiry.
Obviously, I am looking to see if the error message will arise again (when processing the stored procedure) -- when trying to debug earlier, was when the .cs linking seem to got disturbed etc.
Is it possible to debud remotely? (as failed earlier)
ASKER
ok -- just got your @page update ... will do this first
ASKER
applied the @page change -- the button double-clicking is now working (via .cs file) and the other MyButtonClickHandler(objec t sender, EventArgs e) is not visible ok and functional.
ASKER
no errors or warning are appearing now :-) when compiling page/site
ASKER
ok -- I think we are making progress...
so far as, the page compiles, displays ok, and I can press submit (via the web browser) without getting any processing error messages etc.
the form indicates that the database table has been updated (checking rows affected status), but when I check the actual database table in question - there is no updating going on.
so far as, the page compiles, displays ok, and I can press submit (via the web browser) without getting any processing error messages etc.
the form indicates that the database table has been updated (checking rows affected status), but when I check the actual database table in question - there is no updating going on.
ASKER
I am getting this warning now:
Warning 1 The type 'FORTUNE.LeadSourceProvide rs.CreateN ewLeadSour ceProvider ' in 'c:\WINDOWS\Microsoft.NET\ Framework\ v2.0.50727 \Temporary ASP.NET Files\staging.one-trust.co .uk\b2c1e4 7d\c616ae6 e\App_Web_ createnewl eadsourcep rovider.as px.905d605 a.lx9trvbk .0.cs' conflicts with the imported type 'FORTUNE.LeadSourceProvide rs.CreateN ewLeadSour ceProvider ' in 'c:\WINDOWS\Microsoft.NET\ Framework\ v2.0.50727 \Temporary ASP.NET Files\staging.one-trust.co .uk\b2c1e4 7d\c616ae6 e\assembly \dl3\e3fbb 1f6\4e0d36 27_d6e3c70 1\FORTUNE. DLL'. Using the one in 'c:\WINDOWS\Microsoft.NET\ Framework\ v2.0.50727 \Temporary ASP.NET Files\staging.one-trust.co .uk\b2c1e4 7d\c616ae6 e\App_Web_ createnewl eadsourcep rovider.as px.905d605 a.lx9trvbk .0.cs'. c:\WINDOWS\Microsoft.NET\F ramework\v 2.0.50727\ Temporary ASP.NET Files\staging.one-trust.co .uk\b2c1e4 7d\c616ae6 e\App_Web_ createnewl eadsourcep rovider.as px.905d605 a.lx9trvbk .0.cs 313
-------------
Source :: Line 312 onwards as follows:
[System.Runtime.CompilerSe rvices.Com pilerGloba lScopeAttr ibute()]
public class leadsourceproviders_create newleadsou rceprovide r_aspx : global::FORTUNE.LeadSource Providers. CreateNewL eadSourceP rovider, System.Web.IHttpHandler {
private static bool @__initialized;
private static object @__stringResource;
private static object @__fileDependencies;
public leadsourceproviders_create newleadsou rceprovide r_aspx() {
string[] dependencies;
#line 912304 "http://server//staging.one-trust.co.uk/LeadSourceProviders/CreateNewLeadSourceProvider.aspx.cs"
((System.Web.UI.Page)(this )).AppRela tiveVirtua lPath = "~/LeadSourceProviders/Cre ateNewLead SourceProv ider.aspx" ;
#line default
#line hidden
if ((global::ASP.leadsourcepr oviders_cr eatenewlea dsourcepro vider_aspx .@__initia lized == false)) {
global::ASP.leadsourceprov iders_crea tenewleads ourceprovi der_aspx.@ __stringRe source = this.ReadStringResource();
dependencies = new string[2];
dependencies[0] = "~/LeadSourceProviders/Cre ateNewLead SourceProv ider.aspx" ;
dependencies[1] = "~/LeadSourceProviders/Cre ateNewLead SourceProv ider.aspx. cs";
global::ASP.leadsourceprov iders_crea tenewleads ourceprovi der_aspx.@ __fileDepe ndencies = this.GetWrappedFileDepende ncies(depe ndencies);
global::ASP.leadsourceprov iders_crea tenewleads ourceprovi der_aspx.@ __initiali zed = true;
}
this.Server.ScriptTimeout = 30000000;
}
Warning 1 The type 'FORTUNE.LeadSourceProvide
-------------
Source :: Line 312 onwards as follows:
[System.Runtime.CompilerSe
public class leadsourceproviders_create
private static bool @__initialized;
private static object @__stringResource;
private static object @__fileDependencies;
public leadsourceproviders_create
string[] dependencies;
#line 912304 "http://server//staging.one-trust.co.uk/LeadSourceProviders/CreateNewLeadSourceProvider.aspx.cs"
((System.Web.UI.Page)(this
#line default
#line hidden
if ((global::ASP.leadsourcepr
global::ASP.leadsourceprov
dependencies = new string[2];
dependencies[0] = "~/LeadSourceProviders/Cre
dependencies[1] = "~/LeadSourceProviders/Cre
global::ASP.leadsourceprov
global::ASP.leadsourceprov
}
this.Server.ScriptTimeout = 30000000;
}
ASKER
I have created a new file (striped down the code to near bear essentials) -- as there is still no updating on the database table (the stored procedure is still the same).
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CreateNewLeadSou rceProvide r.aspx.cs" Inherits="LeadSources_Crea teNewLeadS ourceProvi der" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<asp:Button ID="Button_CreateNewLeadSo urceProvid er" runat="server" OnClick="Button_CreateNewL eadSourceP rovider_Cl ick"
Text="Create New Lead Source Provider" Width="239px" /> </div>
</form>
</body>
</html>
.cs file as follows:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls. WebParts;
using System.Web.UI.HtmlControls ;
public partial class LeadSources_CreateNewLeadS ourceProvi der : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button_CreateNewLeadSource Provider_C lick(objec t sender, EventArgs e)
{
SqlDataSource FORTUNESQLDataSource = new SqlDataSource();
FORTUNESQLDataSource.Conne ctionStrin g = ConfigurationManager.Conne ctionStrin gs["FORTUN EConnectio nString"]. ToString() ;
FORTUNESQLDataSource.Inser tCommandTy pe = SqlDataSourceCommandType.S toredProce dure;
FORTUNESQLDataSource.Inser tCommand = "BackOffice.InsertNewLeadS ourceProvi der";
FORTUNESQLDataSource.Inser tParameter s.Add("@Le adSourcePr oviderName ", "Test 1");
FORTUNESQLDataSource.Inser tParameter s.Add("@Co mpanyRegis teredName" , "Test 1");
FORTUNESQLDataSource.Inser tParameter s.Add("@Co mpanyRegis trationNum ber", "1234567890");
FORTUNESQLDataSource.Inser tParameter s.Add("@Va lueAddTaxR egistered" , "TRUE");
FORTUNESQLDataSource.Inser tParameter s.Add("@Va lueAddTaxR egistratio nRef", "1234567890");
FORTUNESQLDataSource.Inser tParameter s.Add("@Sw itchboard" , "1234");
FORTUNESQLDataSource.Inser tParameter s.Add("@La ndlineFax" , "1234");
FORTUNESQLDataSource.Inser tParameter s.Add("@We bsiteURL", "test.com");
FORTUNESQLDataSource.Inser tParameter s.Add("@Em ailAddress ", "post@test.com");
FORTUNESQLDataSource.Inser tParameter s.Add("@Co mplianceCo nfirmed", "TRUE");
int RowsAffected = 0;
try
{
RowsAffected = FORTUNESQLDataSource.Inser t();
}
catch (Exception)
{
SQL_FailureHandler();
}
finally
{
FORTUNESQLDataSource = null;
}
}
private void SQL_FailureHandler()
{
// TODO SQL Failure Handler needs to be scripted
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CreateNewLeadSou
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<asp:Button ID="Button_CreateNewLeadSo
Text="Create New Lead Source Provider" Width="239px" /> </div>
</form>
</body>
</html>
.cs file as follows:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.
using System.Web.UI.HtmlControls
public partial class LeadSources_CreateNewLeadS
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button_CreateNewLeadSource
{
SqlDataSource FORTUNESQLDataSource = new SqlDataSource();
FORTUNESQLDataSource.Conne
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
FORTUNESQLDataSource.Inser
int RowsAffected = 0;
try
{
RowsAffected = FORTUNESQLDataSource.Inser
}
catch (Exception)
{
SQL_FailureHandler();
}
finally
{
FORTUNESQLDataSource = null;
}
}
private void SQL_FailureHandler()
{
// TODO SQL Failure Handler needs to be scripted
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks -- In the meantime, I have create a locally hosted (asp development server site) project containing the files as above (still connecting remotely to the same SQL 2005 server.
Purpose being -- in order to be able to debug the solution (as the remote debugging seemed not possible on the web server).
Still having the same issue -- the database table is not being updated. (but no errors now -- even after running the page) -- but obviously not quite there yet with a successful database update.
Purpose being -- in order to be able to debug the solution (as the remote debugging seemed not possible on the web server).
Still having the same issue -- the database table is not being updated. (but no errors now -- even after running the page) -- but obviously not quite there yet with a successful database update.
ASKER
Do I need to create a 'Trigger' as well in order for the update to happen -- or does the Stored Procedure cater for this already?
ASKER
When submitting form, I am getting the following error (via the Studio Output window):
A first chance exception of type 'System.Data.SqlClient.Sql Exception' occurred in System.Web.dll
A first chance exception of type 'System.Data.SqlClient.Sql
ASKER
I managed to get this resolved in the end, by using the different structure as recommended at the top of this thread. Modified a couple of lines to fit ... but wanted to add this to the conversation to confirm how it was solved and hopefully be useful for anyone else accordingly.
"
Good day,
you can try this code to retrieve and execute Stored procedures:
System.Data.SqlClient.SqlC ommand scCommand = new System.Data.SqlClient.SqlC ommand();
Command.CommandType = System.Data.CommandType.St oredProced ure;
Command.CommandText = StoredProcedureName;
Command.Parameters.Add("@R ETURN_VALU E", System.Data.SqlDbType.Int) .Direction = ParameterDirection.ReturnV alue;
SqlConnection Connection1 = new SqlConnection(ConnectionSt ring);
Command.Parameters.AddWith Value("@Co lumnName", ValueToInsert);
try
{
Connection1.Open();
Command.Connection = Connection1;
Command.ExecuteNonQuery();
}
catch (Exception ex)
{
//handle error here
}
finally
{
Connection1.Close();
}
Use this model. Hope it helps
"
modified script as follows___________________ __________ _
protected void Button_CreateNewDatabaseEn try_Click( object sender, EventArgs e)
{
SqlDataSource MySQLDataSource = new SqlDataSource();
MySQLDataSource.Connection String = ConfigurationManager.Conne ctionStrin gs["MyConn ectionStri ng"].ToStr ing();
System.Data.SqlClient.SqlC ommand scCommand = new System.Data.SqlClient.SqlC ommand();
scCommand.CommandType = System.Data.CommandType.St oredProced ure;
scCommand.CommandText = "BackOffice.InsertTestText ";
scCommand.Parameters.Add(" @RETURN_VA LUE", System.Data.SqlDbType.Int) .Direction = ParameterDirection.ReturnV alue;
SqlConnection Connection1 = new SqlConnection(MySQLDataSou rce.Connec tionString );
scCommand.Parameters.AddWi thValue("@ TestText", "Test Entry");
try
{
Connection1.Open();
scCommand.Connection = Connection1;
scCommand.ExecuteNonQuery( );
}
catch (Exception ex)
{
//handle error here
}
finally
{
Connection1.Close();
}
}
Again, thank you for both contributors for their valued and apprieated contributions today :-)
"
Good day,
you can try this code to retrieve and execute Stored procedures:
System.Data.SqlClient.SqlC
Command.CommandType = System.Data.CommandType.St
Command.CommandText = StoredProcedureName;
Command.Parameters.Add("@R
SqlConnection Connection1 = new SqlConnection(ConnectionSt
Command.Parameters.AddWith
try
{
Connection1.Open();
Command.Connection = Connection1;
Command.ExecuteNonQuery();
}
catch (Exception ex)
{
//handle error here
}
finally
{
Connection1.Close();
}
Use this model. Hope it helps
"
modified script as follows___________________
protected void Button_CreateNewDatabaseEn
{
SqlDataSource MySQLDataSource = new SqlDataSource();
MySQLDataSource.Connection
System.Data.SqlClient.SqlC
scCommand.CommandType = System.Data.CommandType.St
scCommand.CommandText = "BackOffice.InsertTestText
scCommand.Parameters.Add("
SqlConnection Connection1 = new SqlConnection(MySQLDataSou
scCommand.Parameters.AddWi
try
{
Connection1.Open();
scCommand.Connection = Connection1;
scCommand.ExecuteNonQuery(
}
catch (Exception ex)
{
//handle error here
}
finally
{
Connection1.Close();
}
}
Again, thank you for both contributors for their valued and apprieated contributions today :-)
ASKER
I am certain that this has fixed the initial question (many thanks).
There is now the following error message:
Server Error in '/' Application.
--------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceExcept
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
FORTUNE.LeadSourceProvider
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.WebControls.
System.Web.UI.Page.RaisePo
System.Web.UI.Page.RaisePo
System.Web.UI.Page.Process
--------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
this is related to something else needs looking at? (do I need to submit this as a seperate question or can apend to this existing thread?)
I am working remotely on the site/sql server -- yet I am seeing a local c:/ drive reference above in the error.
Many thanks,
-andrew.