473,386 Members | 1,630 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,386 software developers and data experts.

how to build & set a custom update command

Neo
I konw that one can make use of the default UpdateCommand in the DataAdapter
to save changes back into the underlying data source.
But i was wondering how one could build a custom update command & set this
into the DataAdapter & when the Update method of the Data Adapter is issued,
then this update command should be used.

Esp, if the table is Customer with the following fields,
ID = Primary Key Field (Integer)
Name = Varchar
Male = Bit

UpdateCmd = "UPDATE Contacts SET Name=@Name, Male=@Male WHERE ID=@ID"
But to do this, i need to add the parameters into the update command of the
format,

UpDataCmd.Parameters.Add("@Name", <Column Data Type>, <Column Size>, "Name")
UpDataCmd.Parameters.Add("@Male", <Column Data Type>, <Column Size>, "Male")
UpDataCmd.Parameters.Add("@ID", <Column Data Type>, <Column Size>, "ID")

Now, is there a way i could determine the above,
the Data Type of the columns (SQL Data type) & the Size of the fields (in
the SQL Table).
I don't mind querying the data base to get this info).

Thanx,

Neo
Nov 21 '05 #1
1 2823
Neo
Basically what i need is a way of determining the SQL Data type of a column
& the Size of a column.
I found one way of doing this, but may not be the best (then again, this is
what i could comeup with),

I make use of the SQLCommandBuilder class to build the Update command,
& using this generated Update Command, i loop through the Parameters
collection,
& from there i determin the SQLDataType & the size of the field (from the
Parameter object attributes).

Neo

"Neo" <ne*@learning.net> wrote in message
news:#W**************@TK2MSFTNGP14.phx.gbl...
I konw that one can make use of the default UpdateCommand in the DataAdapter to save changes back into the underlying data source.
But i was wondering how one could build a custom update command & set this
into the DataAdapter & when the Update method of the Data Adapter is issued, then this update command should be used.

Esp, if the table is Customer with the following fields,
ID = Primary Key Field (Integer)
Name = Varchar
Male = Bit

UpdateCmd = "UPDATE Contacts SET Name=@Name, Male=@Male WHERE ID=@ID"
But to do this, i need to add the parameters into the update command of the format,

UpDataCmd.Parameters.Add("@Name", <Column Data Type>, <Column Size>, "Name") UpDataCmd.Parameters.Add("@Male", <Column Data Type>, <Column Size>, "Male") UpDataCmd.Parameters.Add("@ID", <Column Data Type>, <Column Size>, "ID")

Now, is there a way i could determine the above,
the Data Type of the columns (SQL Data type) & the Size of the fields (in
the SQL Table).
I don't mind querying the data base to get this info).

Thanx,

Neo

Nov 21 '05 #2

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

Similar topics

3
by: Gordon Watts | last post by:
Hi there, I've got a special header file which I run an small external program over to produce a .cpp file that I want to have my project build. The special header file includes a second header...
1
by: Neo | last post by:
I konw that one can make use of the default UpdateCommand in the DataAdapter to save changes back into the underlying data source. But i was wondering how one could build a custom update command &...
2
by: Peter Ritchie | last post by:
In VS/VC 2003: Simple question: for the Custom Build Step for the project (right click the project in the Solution Explorer, select "Properties", select the "Custom Build Step" in the...
6
by: Darren | last post by:
hi y'all! i pretty much wanted to do a custom form where users can change their password to the database as they like.. the problem i encountered is that it seems that when a valid user enter...
5
by: Al | last post by:
Hi all We have created a xml file that imports a single project using the Import element. This project compiles to a class library, but has references to two other projects that are also class...
0
by: Michael Russell | last post by:
Hi, I'm beginning the process of moving some projects from VS.Net 7 to VS2005. I'm having problems getting a Custom Build Step to work. In the dialog for the header file I want to perform the...
1
by: AlexZh | last post by:
Hi, I'd like to stop command line build by one project build failed. To do that I've created simple AddIn (see code below), that works fine for IDE and does not work for command line. In the AddIn...
1
by: Michael Russell | last post by:
Hi all, Sorry for the repost, but I never received any response when I first asked this a few weeks ago. I would really appreciate some feedback on this, it's driving me nuts... I'm...
0
by: mauro | last post by:
Hi all, I am trying to make a package distribution containing some extension module written in C. The problem is that when I run setup.py some files are generated in the wrong position. Suppose...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.