473,395 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

get/set SourceColumn values manually?

Hi,

Is there a way to get/set (or override) SqlParameter.SourceColumn values
manually?

Code example:
// create DeleteCommand by SourceColumn
strSQL = "DELETE FROM [MyTable] WHERE (ID=@ID)";
using (sqlData.DeleteCommand = new SqlCommand(strSQL, sqlConn))
{
sqlParam = sqlData.DeleteCommand.Parameters.Add("@ID", SqlDbType.Int);
sqlParam.SourceColumn = "ID";
}

// Get/Set parameter values manually
GetSetParameterValuesManually();

I want to find out the values of @ID in the GetSetParameterValuesManually()
function, row by row, so that I can delete corresponding data in OTHER tables
that use the ID column as the link.

I suppose if there was a way to DELETE from multiple tables using IDs to
link each other it would work, but I don't know if there is a way to do that.

Please help and thanks for your time.
Nov 7 '08 #1
2 3097
R Reyes,

Have you looked into creating foreign key relationships in the database?
I know in SQL Server, at least, there is an option to cascade deletes, so
that things that are related to the record being deleted will be deleted as
well.

The SourceColumn parameter is not read-only, so you can set the
SourceColumn parameter to whatever you wish.

If you have the DataSet that you are using to get the values from, you
can just use the SourceColumn property to get the value that will be used.
If you don't have access to the data set, there isn't anything you can do.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"R Reyes" <RR****@discussions.microsoft.comwrote in message
news:EF**********************************@microsof t.com...
Hi,

Is there a way to get/set (or override) SqlParameter.SourceColumn values
manually?

Code example:
// create DeleteCommand by SourceColumn
strSQL = "DELETE FROM [MyTable] WHERE (ID=@ID)";
using (sqlData.DeleteCommand = new SqlCommand(strSQL, sqlConn))
{
sqlParam = sqlData.DeleteCommand.Parameters.Add("@ID", SqlDbType.Int);
sqlParam.SourceColumn = "ID";
}

// Get/Set parameter values manually
GetSetParameterValuesManually();

I want to find out the values of @ID in the
GetSetParameterValuesManually()
function, row by row, so that I can delete corresponding data in OTHER
tables
that use the ID column as the link.

I suppose if there was a way to DELETE from multiple tables using IDs to
link each other it would work, but I don't know if there is a way to do
that.

Please help and thanks for your time.
Nov 9 '08 #2
"If you have the DataSet that you are using to get the values from, you can
just use the SourceColumn property to get the value that will be used. If you
don't have access to the data set, there isn't anything you can do."

This might work. I'll change the values of the data set BEFORE getting the
sourcecolumn values instead of after. Thanks

"Nicholas Paldino [.NET/C# MVP]" wrote:
R Reyes,

Have you looked into creating foreign key relationships in the database?
I know in SQL Server, at least, there is an option to cascade deletes, so
that things that are related to the record being deleted will be deleted as
well.

The SourceColumn parameter is not read-only, so you can set the
SourceColumn parameter to whatever you wish.

If you have the DataSet that you are using to get the values from, you
can just use the SourceColumn property to get the value that will be used.
If you don't have access to the data set, there isn't anything you can do.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"R Reyes" <RR****@discussions.microsoft.comwrote in message
news:EF**********************************@microsof t.com...
Hi,

Is there a way to get/set (or override) SqlParameter.SourceColumn values
manually?

Code example:
// create DeleteCommand by SourceColumn
strSQL = "DELETE FROM [MyTable] WHERE (ID=@ID)";
using (sqlData.DeleteCommand = new SqlCommand(strSQL, sqlConn))
{
sqlParam = sqlData.DeleteCommand.Parameters.Add("@ID", SqlDbType.Int);
sqlParam.SourceColumn = "ID";
}

// Get/Set parameter values manually
GetSetParameterValuesManually();

I want to find out the values of @ID in the
GetSetParameterValuesManually()
function, row by row, so that I can delete corresponding data in OTHER
tables
that use the ID column as the link.

I suppose if there was a way to DELETE from multiple tables using IDs to
link each other it would work, but I don't know if there is a way to do
that.

Please help and thanks for your time.
Nov 9 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: David Sworder | last post by:
With a standard enum, values are automatically assigned. public enum MyEnum{Happy,Sad,Angry,Grandpa}; ....but what about a bitflag enum? public enum MyEnum:int{ FalseTeeth=0x00000001...
3
by: Don | last post by:
Hi: I want to limit the values that can be entered for particular attributes. 1) I have created an XSD from my XML document. 2) I dropped that XSD file into the following directory...
7
by: Dave Hopper | last post by:
Hi I posted a question recently regarding problems I am having getting a value from a list box to use in a query. I got a lot of help, for which I thank you and it's nearly working! But I need...
2
by: Wyllielass | last post by:
Hi all, I've looked through the archives and I haven't been able to find or at least recognize the solution to my problem. I have a student data base, Access 2000. I have 12 school districts. ...
1
by: Tumurbaatar S. | last post by:
Hi! In old ASP I used Application collection to store configuration settings like ADO connection string. In .NET, it seems, the preferred method is using Web.config file. Yes? If I'm right then...
6
by: cipher | last post by:
I have some constant values in my web service that my client application will require. Having to keep server side and client side definitions insync is tedious. I am trying to do something like...
6
by: Materialised | last post by:
Hi All I have been searching the net on this for the last couple of hours to no avail. I need to fill a datagridview control based on the values entered in 2 text boxes. However I cant for...
9
by: =?Utf-8?B?UGV0ZXJX?= | last post by:
I have a TabControl on a Windows form in which I have various tab pages each with a DataGridView, the first column of which is a DataGridViewCheckBoxColumn and subsequent columns being...
11
by: Jon Slaughter | last post by:
This is more of a C++ question but I guess it applies equally well to C#. Is there a way to declare an enum where the values assigned to the fields is incremented by something rather than 1. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.