473,808 Members | 2,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Param eters.Add("@Nam e", <Column Data Type>, <Column Size>, "Name")
UpDataCmd.Param eters.Add("@Mal e", <Column Data Type>, <Column Size>, "Male")
UpDataCmd.Param eters.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 2861
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 SQLCommandBuild er 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.n et> wrote in message
news:#W******** ******@TK2MSFTN GP14.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.Param eters.Add("@Nam e", <Column Data Type>, <Column Size>, "Name") UpDataCmd.Param eters.Add("@Mal e", <Column Data Type>, <Column Size>, "Male") UpDataCmd.Param eters.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
2065
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 file. I'm using VS.NET 2003 and I'd like to automate the process. To automate this I used the Custom Build Step associated with my first input file. I specified the output file, and also the second header as an additional dependency, and add the...
1
913
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 & 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
2
1738
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 "Configuration Properties" tree at the left, then select "General" under "Custom Build Step"), what is the implicitly dependent file? My situation is, there is a file I would like to copy after the build; but, only if it has changed. I've added a "copy...
6
1839
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 their new password, the new password is not reflected in the respective tables and after clicking the cmdChangePW, nothing happen despite me puttin a msgbox "Password changed" after running the SQL.
5
4473
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 libraries. We are having a path reference issue for the depending projects; if the build is started in another directory than that of the imported project. (It's a simple cannot find project xyz.csproj, build fails.) If we place the xml file in...
0
1052
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 custom step on, I copy and paste the command line: $(QTDIR)\bin\moc.exe "..\Messenger.h" -o ".\moc_Messenger.cpp" I also set description, outputs, additional dependencies ($(QTDIR)\bin\moc.exe), and click Ok. I can open the dialog up again,
1
2735
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 I have only two non-trivial methods: In OnConnection I add my event handler to OnBuildProjConfigDone, and in the event handler I executed Build.Cancel. In IDE - no problem. When I execute I see that AddIn works and Build.Cancel is called but...
1
2361
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 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 custom step on,
0
1175
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 that this is my setup.py: from distutils.core import setup, Extension setup(name='foo', package_dir = {"foo" : "src"},
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10628
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10373
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10113
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9195
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.