Debugging The SQL Delete Command

Mar 16, 2008

What's the best way to debug the SQL commands with parameters? My Formview performs the INSERT and EDIT commands fine -- and I can see the results in the tables. However, my Delete command crashes -- see the error below. 


I assume that the problem is a formatting issue with an input parameter -- i see there are equality tests for the parameters before the delete is allowed --


How Can I look at these parameters to inspect them? All the types on the paranmeters look fine to me!!


          ---Jim 


 


Server Error in '/GVOps4' Application.


Input string was not in a correct format.

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.FormatException: Input string was not in a correct format.

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:





[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2755599
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +112
System.String.System.IConvertible.ToInt32(IFormatProvider provider) +43
System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +293
System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +264
System.Web.UI.WebControls.SqlDataSourceView.AddParameters(DbCommand command, ParameterCollection reference, IDictionary parameters, IDictionary exclusionList, String oldValuesParameterFormatString) +557
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDelete(IDictionary keys, IDictionary oldValues) +615
System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) +75
System.Web.UI.WebControls.FormView.HandleDelete(String commandArg) +832
System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +535
System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +132
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746


 

 <asp:SqlDataSource ID="PilotReportDetail" runat="server"

ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

DeleteCommand="DELETE FROM [FlightReport] WHERE [FlightReportID] = @original_FlightReportID AND [DateTimeEntered] = @original_DateTimeEntered AND [DateTimeFlown] = @original_DateTimeFlown AND [PilotID] = @original_PilotID AND [AircraftID] = @original_AircraftID AND [CameraPodID] = @original_CameraPodID AND [OrderID] = @original_OrderID AND [FlightHours] = @original_FlightHours AND [FlightSegments] = @original_FlightSegments AND [ReflyReason] = @original_ReflyReason" InsertCommand="INSERT INTO [FlightReport] ([DateTimeEntered], [DateTimeFlown], [PilotID], [AircraftID], [CameraPodID], [OrderID], [FlightHours], [FlightSegments], [ReflyReason]) VALUES (@DateTimeEntered, @DateTimeFlown, @PilotID, @AircraftID, @CameraPodID, @OrderID, @FlightHours, @FlightSegments, @ReflyReason)"

OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [FlightReport] WHERE ([FlightReportID] = @FlightReportID)"

UpdateCommand="UPDATE [FlightReport] SET [DateTimeEntered] = @DateTimeEntered, [DateTimeFlown] = @DateTimeFlown, [PilotID] = @PilotID, [AircraftID] = @AircraftID, [CameraPodID] = @CameraPodID, [OrderID] = @OrderID, [FlightHours] = @FlightHours, [FlightSegments] = @FlightSegments, [ReflyReason] = @ReflyReason WHERE [FlightReportID] = @original_FlightReportID AND [DateTimeEntered] = @original_DateTimeEntered AND [DateTimeFlown] = @original_DateTimeFlown AND [PilotID] = @original_PilotID AND [AircraftID] = @original_AircraftID AND [CameraPodID] = @original_CameraPodID AND [OrderID] = @original_OrderID AND [FlightHours] = @original_FlightHours AND [FlightSegments] = @original_FlightSegments AND [ReflyReason] = @original_ReflyReason">

<SelectParameters><asp:ControlParameter ControlID="GridView1" Name="FlightReportID"

PropertyName="SelectedValue" Type="Int32" />

</SelectParameters>

<DeleteParameters>

<asp:Parameter Name="original_FlightReportID" Type="Int32" />

<asp:Parameter Name="original_DateTimeEntered" Type="DateTime" />

<asp:Parameter Name="original_DateTimeFlown" Type="DateTime" />

<asp:Parameter Name="original_PilotID" Type="Int32" />

<asp:Parameter Name="original_AircraftID" Type="Int32" />

<asp:Parameter Name="original_CameraPodID" Type="Int32" />

<asp:Parameter Name="original_OrderID" Type="Int32" />

<asp:Parameter Name="original_FlightHours" Type="Double" />

<asp:Parameter Name="original_FlightSegments" Type="Int32" />

<asp:Parameter Name="original_ReflyReason" Type="Int32" />

</DeleteParameters>

View 2 Replies


ADVERTISEMENT

Debugging In SSIS - Immediate And Command Windows

Jan 20, 2006

Hi everyone,
I am having a difficult time debugging a package that I'm working on. I read in BOL that the immediate window should be an option during debugging but I can't find it anywhere(nor can I enable it), and I was planning on using it to access an oledb source property that is using an expression. Is the command window the same as immediate? I didn't orignally think so but I'm not sure. What is the syntax to use for this once I find it?
Thanks,
Adrian

View 2 Replies View Related

When Debugging, Do You Have To Shut Down And Restart BIDS Every Time You Rebuild The Custom Component That You're Debugging?

Jul 9, 2006

Hi,

I have found that when I'm debugging a custom component in BIDS that I've created in another instance of Visual Studio, every time I rebuild the component I have to shutdown and restart BIDS and then reattach to the BIDS process. Which is pretty time consuming... And if I find a small error in my custom component when debugging then I don't seem to be allowed to make any changes to the code unless I stop debugging and go through the process above.

Am I missing something here? Or do I really have to manually go through these steps every time I want to change code in the component I'm debugging?

Can I automate the process with MSBuild or NAnt? If so, is there an example of this anywhere?

Thanks in advance,

Lawrie.

View 1 Replies View Related

Cannot Use Alias In Delete Command

Dec 27, 2000

Why cannot I use alias in delete command when I join two table.

My query is as follows.
delete from ikw_indexed_form_approved where exists(select * from ikw_router
where ikw_indexed_form_approved.ikw_subscription_id=ikw_ subscription_id
and ikw_indexed_form_approved.ikw_indexed_name='centra al corp'
and ikw_indexed_form_approved.content_code='html'
and ikw_indexed_form_approved.ikw_subscription_id=1)

if I use like this it gives me an error
delete from ikw_indexed_form_approved A where exists(select * from ikw_router
where A.ikw_subscription_id=ikw_subscription_id
and A.ikw_indexed_name='centraal corp'
and A.content_code='html'
and A.ikw_subscription_id=1)

Your help will be appreciated.
Thanks in advance

View 3 Replies View Related

Delete Command Failed

Nov 10, 1999

Hi

I am using SQL 6.5. I have a master table which is referenced by more than 35 tables. When I try to
delete a record from the table, i am getting this message

Msg 431, Level 16, State 0
Unable to bind foreign key constraint. Too many tables involved in query.

SQL 6.5 maximum 31 foreign key references. I was wondering is there any way to delete those
records. (i don't want to drop the foreign constraints)

SQL 7.0 supports maximum 63 foreign key references.

Thanks in advance

Moorthy.

View 1 Replies View Related

Runtime Sqldatasource Delete Command

Aug 12, 2006

i need to dyanamically generate my SQL commands so to do that i am generating sqldatasource commands programmatically rather declaratively. SELECT commands seems to work fine but DELETE isnt doing anything, here is my code:
 
SqlDataSource sdsConsultant = new SqlDataSource();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
loadDataSet();  //it just loads dataset used by formview
initializeSDS();
}


}
protected void initializeSDS()
{
string strConnection = ConfigurationManager.ConnectionStrings["myDB"].ToString();
sdsConsultant.ConnectionString = strConnection;

//SELECT
sdsConsultant.SelectCommand = "SELECT * FROM Consultants WHERE (id=@id)";
QueryStringParameter id = new QueryStringParameter("id", "id");
sdsConsultant.SelectParameters.Add(id);

//DELETE
sdsConsultant.DeleteCommand = "DELETE * FROM Consultants WHERE (id=@id2)";
QueryStringParameter id2 = new QueryStringParameter("id2", "id");
sdsConsultant.DeleteParameters.Add(id2);

//UPDATE
Page.Controls.Add(sdsConsultant);
FormView1.DataSource = sdsConsultant;
FormView1.DataBind();
}
 
my formview control looks like:
<asp:FormView DefaultMode="Edit" ID="FormView1" runat="server" DataKeyNames="id"
OnItemDeleted="FormView1_ItemDeleted"
OnItemDeleting="FormView1_ItemDeleting">
 
the DELETE doesnt execute and the OnItemDeleted event doesnt do anything either. am i doing something wrong here? plz help
 

View 2 Replies View Related

Tablediff Utility Without 'delete' Command.

Apr 23, 2008



I am presently using 'tablediff' utility of SQLServer 2005 to compare tables located on two different servers. My real intension is to backup data from Serv1 to Serv2, except that I wish to update the tables on server2 with only newly inserted rows and updated rows and NOT deleted rows.

In short, I want the final .sql file generated by the tablediff utility to contain only 'Insert' and 'Update' statements and NOT 'Delete' statements.

I hope someone can help me in this regard.

Thank you,
Little_Birdie.

View 6 Replies View Related

Returnvalue Not Accepted In Update / Delete Command

Dec 13, 2005

Hi,
I tried to use the RETURN_VALUE of a stored procedure in updata / delete commands with a sql-datasource and a stored procedure.
The thing works fine with the insert command.But it fails with "too many arguments..." in delete / update.
I also tried to handle the updating event like this:
protected void sqldsReportSelect_Updating(object sender, SqlDataSourceCommandEventArgs e) {   SqlParameter sqP = new SqlParameter("RETURN_VALUE", SqlDbType.Int);   sqP.Direction = ParameterDirection.ReturnValue;   e.Command.Parameters.Add(sqP);}
It brings the same error.
Do I make something wrong or is this a bug?
Regards
Manfred

View 2 Replies View Related

Is There A Way To Know The Condition In An Update/Delete Command Inside A SP?

May 7, 2008



Hi to all:

I'm trying to make a sp who generates an export string for everey sql command, for example: Insert, update and delete. In the case of Insert I just have the sp, but in "update" and "delete" commands... how can I know the conditions?..

UDTATE DemoTable SET DemoField=77 WHERE (Condition1 AND Condition2)

....may I use a comparative with 'updated' table?, please help me with your ideas

Thanks a lot.

View 4 Replies View Related

OLEDB Command Usage When Update/delete On Db2

Dec 11, 2007



We have SS2K5 source and DB2 Target. I downloaded and installed MS OLE DB provider for DB2. It is configured correctly. The data insert works fine. But I am having problem with update/delete on DB2 when passing string parameters.

The OLEDB command works fine when I hard code the values:
delete from TableName where Col1='abc' and Col2='xyz'

But when I use parameters the package executes successfully, but the data is not delete on DB2.

Any one having similar experience or solution for this is really appreciated.

Thanks,


View 7 Replies View Related

Get @@rowcount Data From MSSQL Using SqlDataSource With Delete Command

Mar 8, 2007

HiI'm using a simple SqlDataSource to connect to a stored proc to delete a number of rows from different tables.In my SQL im using: DECLARE @table1Count int

DELETE FROM Table1 WHERE id = @new_id

SET @table1Count=@@rowcount

SELECT @table1Count  I'm then using an input box and linking it to the delete control parameter.  Then on a button click event i'm running SqlDataSource1.Delete() which all works fine.  But how do i get the @table1Count back into my aspx page? Thanks 

View 3 Replies View Related

Manually Defined Delete Command Doesn't Work

Feb 16, 2008

Hi,
 i defined a sqldatasource in VWD manually (option specify sql statement) because several tables are involved. I also need a Delete statement, so i defined it also manually.
The select and delete statement are :
 <asp:SqlDataSource ID="SqlDataSource1" runat="server"            ConnectionString="<%$ ConnectionStrings:test %>"                       SelectCommand="SELECT aspnet_Users.UserName as lid, aspnet_Roles.RoleName            as categorie, aspnet_Users.beheerder as beheerder, aspnet_Membership.Email as emailadres FROM aspnet_Users INNER JOIN            aspnet_Membership ON aspnet_Users.UserId = aspnet_Membership.UserId INNER JOIN            aspnet_UsersInRoles ON aspnet_Users.UserId = aspnet_UsersInRoles.UserId inner JOIN            aspnet_Roles ON aspnet_UsersInRoles.RoleId = aspnet_Roles.RoleId order by username"
           DeleteCommand="delete from aspnet_users where userid=@userid">            <DeleteParameters>                <asp:Parameter Name="userid" />            </DeleteParameters>       </asp:SqlDataSource>
My problem is that the Select works, but not the Delete.
Any idea why?
Thanks
tartuffe

View 2 Replies View Related

CAN I Command (INSERT, DELETE, UPDATE) 2 Tables At The Same Time? POSSIBLE? HOW?

Apr 25, 2008

i've read the transact-sql command,
i known that the select command use to retrieve many fields from many tables with one command
select * from table1,table2
yes,
but i ' ve not seen the way to add,delete or update those fields from those tables with one command...

Is it possible? why?
I don't have any idea , can u help me
I want to know the sql commands , if it's possible

thanks for reply,
mochi

View 3 Replies View Related

Master Data Services :: How To Use FORFILES Command To Delete Server Backups

Sep 19, 2015

Recently I constructed a new backup process that I want to institute globally across all my SQL Server 2005 instances, Is there a way I can automate a file deletion process from within SQL Server?

View 2 Replies View Related

SQL 2012 :: FOR FILES Command To Delete Old Backup Files On Remote Server?

Feb 24, 2015

I have the need to delete old backup files via TSQL job. Found this solution online:

PushD "
emoteservershareDIFF" &&(
forfiles -m *DIFF*.sqb -d -1 -c "cmd /c del /q @path"
) & PopD

It works remotely if I run it via command prompt. But when I add this to a TSQL job on my remote SQL instance, it runs without deleting anything. What I'm missing?

View 6 Replies View Related

Defining Command,commandtype And Connectionstring For SELECT Command Is Not Similar To INSERT And UPDATE

Feb 23, 2007

i am using visual web developer 2005 and SQL 2005 with VB as the code behindi am using INSERT command like this        Dim test As New SqlDataSource()        test.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString1").ToString()        test.InsertCommandType = SqlDataSourceCommandType.Text        test.InsertCommand = "INSERT INTO try (roll,name, age, email) VALUES (@roll,@name, @age, @email) "                  test.InsertParameters.Add("roll", TextBox1.Text)        test.InsertParameters.Add("name", TextBox2.Text)        test.InsertParameters.Add("age", TextBox3.Text)        test.InsertParameters.Add("email", TextBox4.Text)        test.Insert() i am using UPDATE command like this        Dim test As New SqlDataSource()        test.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString").ToString()        test.UpdateCommandType = SqlDataSourceCommandType.Text        test.UpdateCommand = "UPDATE try SET name = '" + myname + "' , age = '" + myage + "' , email = '" + myemail + "' WHERE roll                                                         123 "        test.Update()but i have to use the SELECT command like this which is completely different from INSERT and  UPDATE commands   Dim tblData As New Data.DataTable()         Dim conn As New Data.SqlClient.SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated                                                                                Security=True;User Instance=True")   Dim Command As New Data.SqlClient.SqlCommand("SELECT * FROM try WHERE age = '100' ", conn)   Dim da As New Data.SqlClient.SqlDataAdapter(Command)   da.Fill(tblData)   conn.Close()                   TextBox4.Text = tblData.Rows(1).Item("name").ToString()        TextBox5.Text = tblData.Rows(1).Item("age").ToString()        TextBox6.Text = tblData.Rows(1).Item("email").ToString()       for INSERT and UPDATE commands defining the command,commandtype and connectionstring is samebut for the SELECT command it is completely different. why ?can i define the command,commandtype and connectionstring for SELECT command similar to INSERT and UPDATE ?if its possible how to do ?please help me

View 2 Replies View Related

Using A Variable In SSIS - Error - Command Text Was Not Set For The Command Object..

Nov 4, 2006

Hi All,

i am using a OLE DB Source in my dataflow component and want to select rows from the source based on the Name I enter during execution time. I have created two variables,

enterName - String packageLevel (will store the name I enter)

myVar - String packageLevel. (to store the query)

I am assigning this query to the myVar variable, "Select * from db.Users where (UsrName = " + @[User::enterName] + " )"

Now in the OLE Db source, I have selected as Sql Command from Variable, and I am getting the variable, enterName,. I select that and when I click on OK am getting this error.

Error at Data Flow Task [OLE DB Source [1]]: An OLE DB error has occurred. Error code: 0x80040E0C.
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E0C Description: "Command text was not set for the command object.".

Can Someone guide me whr am going wrong?

myVar variable, i have set the ExecuteAsExpression Property to true too.

Please let me know where am going wrong?

Thanks in advance.








View 12 Replies View Related

Do Somebody Know How Long (in Chars) Script(command) Can Be Solved By SQL Command?

Aug 30, 2004

Do somebody know how long (in chars) script(command) can be solved by SQL Command?
Thanks

View 1 Replies View Related

What Command Is Used To Get Back The Privileges Offered By The GRANT Command?

Mar 10, 2007

reply.

View 1 Replies View Related

Command Text Was Not Set For The Command Object Error

Sep 19, 2006

Hi. I am writing a program in C# to migrate data from a Foxpro database to an SQL Server 2005 Express database. The package is being created programmatically. I am creating a separate data flow for each Foxpro table. It seems to be doing it ok but I am getting the following error message at the package validation stage:

Description: An OLE DB Error has occured. Error code: 0x80040E0C.

An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E0C Description: "Command text was not set for the command object".

.........

Description: "component "OLE DB Destination" (22)" failed validation and returned validation status "VS_ISBROKEN".

This is the first time I am writing such code and I there must be something I am not doing correct but can't seem to figure it out. Any help will be highly appreciated. My code is as below:

private bool BuildPackage()

{




// Create the package object

oPackage = new Package();

// Create connections for the Foxpro and SQL Server data

Connections oPkgConns = oPackage.Connections;

// Foxpro Connection

ConnectionManager oFoxConn = oPkgConns.Add("OLEDB");

oFoxConn.ConnectionString = sSourceConnString; // Created elsewhere

oFoxConn.Name = "SourceConnectionOLEDB";

oFoxConn.Description = "OLEDB Connection For Foxpro Database";

// SQL Server Connection

ConnectionManager oSQLConn = oPkgConns.Add("OLEDB");

oSQLConn.ConnectionString = sTargetConnString; // Created elsewhere

oSQLConn.Name = "DestinationConnectionOLEDB";

oSQLConn.Description = "OLEDB Connection For SQL Server Database";

// Add Prepare SQL Task

Executable exSQLTask = oPackage.Executables.Add("STOCK:SQLTask");

TaskHost thSQLTask = exSQLTask as TaskHost;

thSQLTask.Properties["Connection"].SetValue(thSQLTask, "oSQLConn");

thSQLTask.Properties["DelayValidation"].SetValue(thSQLTask, true);

thSQLTask.Properties["ResultSetType"].SetValue(thSQLTask, ResultSetType.ResultSetType_None);

thSQLTask.Properties["SqlStatementSource"].SetValue(thSQLTask, @"C:LPFMigrateLPF_Script.sql");

thSQLTask.Properties["SqlStatementSourceType"].SetValue(thSQLTask, SqlStatementSourceType.FileConnection);

thSQLTask.FailPackageOnFailure = true;



// Add Data Flow Tasks. Create a separate task for each table.

// Get a list of tables from the source folder

arFiles = Directory.GetFileSystemEntries(sLPFDataFolder, "*.DBF");

for (iCount = 0; iCount <= arFiles.GetUpperBound(0); iCount++)

{


// Get the name of the file from the array

sDataFile = Path.GetFileName(arFiles[iCount].ToString());

sDataFile = sDataFile.Substring(0, sDataFile.Length - 4);

oDataFlow = ((TaskHost)oPackage.Executables.Add("DTS.Pipeline.1")).InnerObject as MainPipe;

oDataFlow.AutoGenerateIDForNewObjects = true;



// Create the source component

IDTSComponentMetaData90 oSource = oDataFlow.ComponentMetaDataCollection.New();

oSource.Name = (sDataFile + "Src");

oSource.ComponentClassID = "DTSAdapter.OLEDBSource.1";

// Get the design time instance of the component and initialize the component

CManagedComponentWrapper srcDesignTime = oSource.Instantiate();

srcDesignTime.ProvideComponentProperties();

// Add the connection manager

if (oSource.RuntimeConnectionCollection.Count > 0)

{


oSource.RuntimeConnectionCollection[0].ConnectionManagerID = oFoxConn.ID;

oSource.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(oFoxConn);

}

// Set Custom Properties

srcDesignTime.SetComponentProperty("AccessMode", 0);

srcDesignTime.SetComponentProperty("AlwaysUseDefaultCodePage", true);

srcDesignTime.SetComponentProperty("OpenRowset", sDataFile);

// Re-initialize metadata

srcDesignTime.AcquireConnections(null);

srcDesignTime.ReinitializeMetaData();

srcDesignTime.ReleaseConnections();

// Create Destination component

IDTSComponentMetaData90 oDestination = oDataFlow.ComponentMetaDataCollection.New();

oDestination.Name = (sDataFile + "Dest");

oDestination.ComponentClassID = "DTSAdapter.OLEDBDestination.1";

// Get the design time instance of the component and initialize the component

CManagedComponentWrapper destDesignTime = oDestination.Instantiate();

destDesignTime.ProvideComponentProperties();

// Add the connection manager

if (oDestination.RuntimeConnectionCollection.Count > 0)

{


oDestination.RuntimeConnectionCollection[0].ConnectionManagerID = oSQLConn.ID;

oDestination.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(oSQLConn);

}

// Set custom properties

destDesignTime.SetComponentProperty("AccessMode", 2);

destDesignTime.SetComponentProperty("AlwaysUseDefaultCodePage", false);

destDesignTime.SetComponentProperty("OpenRowset", "[dbo].[" + sDataFile + "]");



// Create the path to link the source and destination components of the dataflow

IDTSPath90 dfPath = oDataFlow.PathCollection.New();

dfPath.AttachPathAndPropagateNotifications(oSource.OutputCollection[0], oDestination.InputCollection[0]);

// Iterate through the inputs of the component.

foreach (IDTSInput90 input in oDestination.InputCollection)

{


// Get the virtual input column collection

IDTSVirtualInput90 vInput = input.GetVirtualInput();

// Iterate through the column collection

foreach (IDTSVirtualInputColumn90 vColumn in vInput.VirtualInputColumnCollection)

{


// Call the SetUsageType method of the design time instance of the component.

destDesignTime.SetUsageType(input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READWRITE);

}

//Map external metadata to the inputcolumn

foreach (IDTSInputColumn90 inputColumn in input.InputColumnCollection)

{


IDTSExternalMetadataColumn90 externalColumn = input.ExternalMetadataColumnCollection.New();

externalColumn.Name = inputColumn.Name;

externalColumn.Precision = inputColumn.Precision;

externalColumn.Length = inputColumn.Length;

externalColumn.DataType = inputColumn.DataType;

externalColumn.Scale = inputColumn.Scale;

// Map the external column to the input column.

inputColumn.ExternalMetadataColumnID = externalColumn.ID;

}

}

}

// Add precedence constraints to the package executables

PrecedenceConstraint pcTasks = oPackage.PrecedenceConstraints.Add((Executable)thSQLTask, oPackage.Executables[0]);

pcTasks.Value = DTSExecResult.Success;

for (iCount = 1; iCount <= (oPackage.Executables.Count - 1); iCount++)

{


pcTasks = oPackage.PrecedenceConstraints.Add(oPackage.Executables[iCount - 1], oPackage.Executables[iCount]);

pcTasks.Value = DTSExecResult.Success;

}

// Validate the package

DTSExecResult eResult = oPackage.Validate(oPkgConns, null, null, null);

// Check if the package was successfully executed

if (eResult.Equals(DTSExecResult.Canceled) || eResult.Equals(DTSExecResult.Failure))

{


string sErrorMessage = "";

foreach (DtsError pkgError in oPackage.Errors)

{


sErrorMessage = sErrorMessage + "Description: " + pkgError.Description + "";

sErrorMessage = sErrorMessage + "HelpContext: " + pkgError.HelpContext + "";

sErrorMessage = sErrorMessage + "HelpFile: " + pkgError.HelpFile + "";

sErrorMessage = sErrorMessage + "IDOfInterfaceWithError: " + pkgError.IDOfInterfaceWithError + "";

sErrorMessage = sErrorMessage + "Source: " + pkgError.Source + "";

sErrorMessage = sErrorMessage + "Subcomponent: " + pkgError.SubComponent + "";

sErrorMessage = sErrorMessage + "Timestamp: " + pkgError.TimeStamp + "";

sErrorMessage = sErrorMessage + "ErrorCode: " + pkgError.ErrorCode;

}

MessageBox.Show("The DTS package was not built successfully because of the following error(s):" + sErrorMessage, "Package Builder", MessageBoxButtons.OK, MessageBoxIcon.Information);

return false;

}

// return a successful result

return true;
}

View 2 Replies View Related

SQL Server 2008 :: Maintenance Plan Delete History Trying To Delete Wrong Files

Sep 11, 2015

I have some simple files but they are failing because the delete history task is failing as it is looking for files in a non existent directory.

It is looking for files in C:Program FilesMicrosoft SQL ServerMSSQL10_50.INSTANCEMSSQLLog whereas it should be looking in C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLLog

how I can get this corrected so I can get the Maintenance Plans to run correctly.

I have tried deleting and recreating the Plan but to no avail

View 0 Replies View Related

Master Data Services :: Hard Delete All Soft Delete Records (members) In Database

May 19, 2012

I am using Master Data Service for couple of months now. I can load, update, merge and soft delete data in MDS. Occasionally we even have to hard delete data from MDS. If we keep on soft deleting records in a MDS table eventually there will be huge number of soft deleted records. Is there an easy way to hard delete all the soft deleted records from all MDS tables in a specific Model.

View 18 Replies View Related

Copy And Delete Table With Foreign Key References(...,...) On Delete Cascade?

Oct 23, 2004

Hello:
Need some serious help with this one...

Background:
Am working on completing an ORM that can not only handles CRUD actions -- but that can also updates the structure of a table transparently when the class defs change. Reason for this is that I can't get the SQL scripts that would work for updating a software on SqlServer to be portable to other DBMS systems. Doing it by code, rather than SQL batch has a chance of making cross-platform, updateable, software...

Anyway, because it needs to be cross-DBMS capable, the constraints are that the system used must work for the lowest common denominator....ie, a 'recipe' of steps that will work on all DBMS's.

The Problem:
There might be simpler ways to do this with SqlServer (all ears :-) - just in case I can't make it cross platform right now) but, with simplistic DBMS's (SqlLite, etc) there is no way to ALTER table once formed: one has to COPY the Table to a new TMP name, adding a Column in the process, then delete the original, then rename the TMP to the original name.

This appears possible in SqlServer too --...as long as there are no CASCADE operations.
Truncate table doesn't seem to be the solution, nor drop, as they all seem to trigger a Cascade delete in the Foreign Table.

So -- please correct me if I am wrong here -- it appears that the operations would be
along the lines of:
a) Remove the Foreign Key references
b) Copy the table structure, and make a new temp table, adding the column
c) Copy the data over
d) Add the FK relations, that used to be in the first table, to the new table
e) Delete the original
f) Done?

The questions are:
a) How does one alter a table to REMOVE the Foreign Key References part, if it has no 'name'.
b) Anyone know of a good clean way to get, and save these constraints to reapply them to the new table. Hopefully with some cross platform ADO.NET solution? GetSchema etc appears to me to be very dbms dependant?
c) ANY and all tips on things I might run into later that I have not mentioned, are also greatly appreciated.

Thanks!
Sky

View 1 Replies View Related

SQL - Cascading Delete, Or Delete Trigger, Maintaining Referential Integrity - PLEASE HELP ME!!!

Nov 13, 2006

I am having great difficulty with cascading deletes, delete triggers and referential integrity.

The database is in First Normal Form.

I have some tables that are child tables with two foreign keyes to two different parent tables, for example:

Table A
/
Table B Table C
/
Table D

So if I try to turn on cascading deletes for A/B, A/C, B/D and C/D relationships, I get an error that I cannot have cascading delete because it would create multiple cascade paths. I do understand why this is happening. If I delete a row in Table A, I want it to delete child rows in Table B and table C, and then child rows in table D as well. But if I delete a row in Table C, I want it to delete child rows in Table D, and if I delete a row in Table B, I want it to also delete child rows in Table D.

SQL sees this as cyclical, because if I delete a row in table A, both table B and table C would try to delete their child rows in table D.

Ok, so I thought, no biggie, I'll just use delete triggers. So I created delete triggers that will delete child rows in table B and table C when deleting a row in table A. Then I created triggers in both Table B and Table C that would delete child rows in Table D.

When I try to delete a row in table A, B or C, I get the error "Delete Statement Conflicted with COLUMN REFERENCE". This does not make sense to me, can anyone explain? I have a trigger in place that should be deleting the child rows before it attempts to delete the parent row...isn't that the whole point of delete triggers?????

This is an example of my delete trigger:

CREATE TRIGGER [DeleteA] ON A
FOR DELETE
AS
Delete from B where MeetingID = ID;
Delete from C where MeetingID = ID;

And then Table B and C both have delete triggers to delete child rows in table D. But it never gets to that point, none of the triggers execute because the above error happens first.

So if I then go into the relationships, and deselect the option for "Enforce relationship for INSERTs and UPDATEs" these triggers all work just fine. Only problem is that now I have no referential integrity and I can simply create unrestrained child rows that do not reference actual foreign keys in the parent table.

So the question is, how do I maintain referential integrity and also have the database delete child rows, keeping in mind that the cascading deletes will not work because of the multiple cascade paths (which are certainly required).

Hope this makes sense...
Thanks,
Josh


View 6 Replies View Related

Delete Syntax To Delete A Record From One Table If A Matching Value Isn't Found In Another

Nov 17, 2006

I'm trying to clean up a database design and I'm in a situation to where two tables need a FK but since it didn't exist before there are orphaned records.

Tables are:

Brokers and it's PK is BID

The 2nd table is Broker_Rates which also has a BID table.

I'm trying to figure out a t-sql statement that will parse through all the recrods in the Broker_Rates table and delete the record if there isn't a match for the BID record in the brokers table.

I know this isn't correct syntax but should hopefully clear up what I'm asking

DELETE FROM Broker_Rates

WHERE (Broker_Rates.BID <> Broker.BID)

Thanks

View 6 Replies View Related

SQL Debugging.

Dec 28, 2004

Hi.

I need to step into a SP on my SQL server. However, I get "Security hasn't been setup correctly on server RADU. SQL debugging terminated."

I read the docs, and I did exactly this (as per the help files):

---------------------------------------------------------------------------------------------------
To configure DCOM on the server for SQL debugging

You may need to download and install DCOM first. If so, go to http://www.microsoft.com/com/resources/downloads.asp for the latest version.

You must have administrator privileges on the machine where you are configuring DCOM.

From the Start menu, choose Run.
In the Open box, type dcomcnfg.exe.
Click OK.
The Component Services dialog box appears.

In the left pane of the Component Services dialog box, expand the Component Services node and find Computers.
Expand the Computers node and find the computer for which you want to configure DCOM.
Right-click the computer and choose Properties from the shortcut menu.
In the Properties dialog box, select the Default COM Security tab.
Under Access Permissions, click Edit Default.
The Access Permission dialog box appears.

If the group or user who needs access does not appear in the list of permissions, click Add.
The Users, Computers, or Groups dialog box appears.

In the Enter the object names to select box, type the name of the group or user who needs access.
Click OK.
The user is now added to the list.

If SYSTEM does not appear in the list of permissions, click Add.
The Users, Computers, or Groups dialog box appears.

In the Enter the object names to select box, type:
SYSTEM
Click OK.
SYSTEM is now added to the list.

In the Access Permission, select Allow for each user you added.
Click OK to close the Properties dialog box.
If you changed any settings in this procedure, restart SQL Server.
---------------------------------------------------------------------------------------------------

However, from inside VSnet IDE. I get the same message ("Security hasn't been setup correctly blah-blah-blah").

I have tried with users 'ASPNet' and 'VSDevelopers'. Which user should I choose ? Is there something else I should do ?

Sure, this is not the end of the world, I can still do the debug from within Query Analyzer, but still, it would be nice not to have to do this.

Thank you.
Alex

View 1 Replies View Related

Debugging?

Aug 15, 2005

Hi,Is there a way to debug an SQL Server stored procedure? I call a number of sp's from my .net app and need a way to step through them.Thank you,

View 4 Replies View Related

SQL Debugging

Dec 8, 1998

Does anyone use SQL debugging? I write pocedures in SQL server useing Developper studio, but i do not find any means to debug stored procedures.
Though i can place a break point to source code of sp_procedure, code is runned a whole.
Is this means only for C++?
Can anyone help me?
I have very large procedures and someteimes it is hard to find an error.

Ludek

View 1 Replies View Related

Can U Help Me Debugging This

Aug 13, 2007

select

if(acr_application.appStatus = 'AOO' then acr_application.appDt,
if(acr_application.appStatus = 'A01' then acr_application.recvdDt,
if(acr_application.appStatus = 'A02' then
(select A.payDt from acr_payment A, acr_reference_no B
where A.refNo = B.acrReferenceNoId and B.refType = 'ACF' and B.appNo =
acr_application.appNo),
if(acr_application.appStatus = ('A03', 'A08'),
(select C.updatedBy from acr_insp_sched C
where C.appNo = acr_application.appNo and C.seqNo =
(select max (D.seqNo) from acr_insp_sched D where D.appNo = C.appNo)),
if (acr_application.appStatus = ('A04', 'A05', 'A06', 'A15'),
(select E.updatedBy from acr_inspection E
where E.appNo = acr_application.appNo and E.seqNo =
(select max (F.seqNo) from acr_inspection F where F.appNo = E.appNo)),
if(acr_application.appStatus = 'A07',
(select G.payDt from acr_payment G, acr_reference_no H
where G.refNo = H.refId and H.refType = 'REI' and H.appNo =
acr_application.appNo),
if(acr_application.appStatus = ('A10', 'A11'), acr_application.approvedDt,
if(acr_application.appStatus = 'A13', acr_application.updatedBy,
if(acr_application.appStatus = 'A14',
(select H.payDt from acr_payment H, acr_reference_no J
where H.refNo = J.refId and J.refType = 'CSB' and J.appNo = acr_application.appNo), null)))))))))

from acr_application

View 4 Replies View Related

Debugging

Aug 21, 2007

In SQLServer 2000 I could easily debug a stored procedure from QA. But I dont know how to debug a sp in SQLServer 2005. I could find nothing to deal with it in SQL Server Management Studio. Can anybody tell me how to do it?

View 6 Replies View Related

Can U Help Me Debugging This I Appreciate Ty

Dec 10, 2007

select
acr_application.appNo as 'applicationNo',
acr_application.facilityName as 'nameOf DrugTesting',
acr_application.adr as 'address',
acr_reference_no.refNo as 'referenceNo',
ref_charge.chargeDesc as 'charges/fee',
acr_reference_no.amount as 'amount',

ref_settings.earlyFileDiscnt as 'pdiscount',
((ref_settings.earlyFileDiscnt / 100) * acr_reference_no.amount) as 'discount',

case when acr_reference_no.earlyFileDiscntDt is not null then acr_reference_no.earlyFileDiscntDt
else
case when '2007-09-29' <= ref_facility.validToDt then date_sub(ref_facility.validToDt, interval (ref_settings.earlyFileDiscntValid + 1) day)
end
end as 'discountValidity',

ref_settings.lateFileDiscnt as 'psurcharge',
((ref_settings.lateFileDiscnt / 100) * acr_reference_no.amount) as 'surcharge',

case when acr_reference_no.lateFileSurchargeDt is not null then acr_reference_no.lateFileSurchargeDt
else
case when '2007-09-29' <= ref_facility.validToDt then ref_facility.validToDt, select a.validTodt from acr_application a where a.appNo = (select max(b.appNo) from acr_application b where b.appNo < acr_application.appNo)
end
end
end as 'surchargeValidity',

'0012 2222 20' as 'accountNumber',
concat('DOH-',acr_reference_no.refNo, '','-85619') as 'accountName',

concat(if(acr_application.ownerTitle is null or acr_application.ownerTitle='','', concat(acr_application.ownerTitle, '')),
acr_application.ownerFname, ' ',
if(acr_application.ownerMname is null or acr_application.ownerMname='','', concat(substr(acr_application.ownerMname,1,1),'.', ' ')),
acr_application.ownerLname, '', '',
if(acr_application.ownerSuffix is null or acr_application.ownerSuffix='','', concat(' ', acr_application.ownerSuffix))) as 'nameOfRepresentative'

case when acr_application.appType = 'INA' then acr_reference_no.amount
else
case when acr_application.appType = 'RNW' then
(if(acr_reference_no.earlyFileDiscnt is not null
and acr_reference_no.earlyFileDiscnt <='2007-09-29',
acr_reference_no.amount + (acr_reference_no.amount * (ref_settings.earlyFileDiscnt / 100))))
else
case when acr_reference_no.earlyFileDiscntDt is not null
and acr_reference.earlyFileDiscntDt > '2007-09-29'
and '2007-09-29' <= ref_facility.validToFt
then acr_reference_no.amount, acr_reference_no.amount + (acr_reference_no.amount * (ref_settings.earlyFileDiscnt / 100))
end
end
end as 'totalCashDeposit',

case when acr_application.appType = 'INA' then date_add(acr_applicationappDt, interval ref_settings.validityAfterAppDayy)
else
case when acr_application.appType = 'RNW' then acr_reference_no.earlyFileDiscntDt
else
case when acr_reference_no.earlyFileDiscntDt is not null and acr_reference_no.earlyFileDiscntDt > '2007-09-29' and '2007-09-29' <= ref_facility.validToDt then ref_facility.validToDt, date_add(ref_facility.validToDt, interval ref_settings.validityAfterAppDay)
end
end
end as 'bankValidity'



from acr_application
left join ref_facility on acr_application.appNo = ref_facility.appNo
left join ref_settings on ref_settings.service = acr_application.service and
ref_settings.ownType = acr_application.ownType and
ref_settings.facilityType = acr_application.facilityType and
ref_settings.institutChar = acr_application.institutChar
left join (acr_reference_no left join ref_charge on acr_reference_no.chargeId = ref_charge.chargeId and acr_reference_no.paid <> 'Y')
on acr_application.appNo = acr_reference_no.appNo

View 4 Replies View Related

SQL Debugging

Jul 20, 2005

My colleagues and I have not been able to successfully set up SQL debugging on a SQL 2000 instance running on Windows 2000.Is there a checklist posted somewhere? We have verified that the SQL Server is not running with System Account Credentials. It runs as a Domain Administrator. We have also verified that everyone has permission to run sp_sdidebug. Does it matter that the Win2K machine is a Domain Controller? Any help would be appreciated.

View 1 Replies View Related

Debugging...

Feb 14, 2008

Hi -

I am new to SSIS but not new to ETL. Is there a way in debugger to debug but not actually update the target table ? In other tools I€™ve used, there was an option setting to not allow update/inserts into the actual table, but would provide a visual dataset so you could see & test with. I haven€™t been able to find this feature in SSIS & was wondering if there is a way to do this.

Thanks -

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved