Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 19th, 2004, 05:29 AM
Registered User
 
Join Date: Aug 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default inserting data into Sql Database

Hi
I have a windows app with a datagrid, sqlDataAdapter, sqlConnection and a dataSet.
I want to input data into text boxes on a Windows App, then by clicking a button insert the data into a data grid and then into my sqldatabase.

Any help please

CodeMonkeys
 
Old August 22nd, 2004, 11:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Ok I soppose ur datagrid has the same value as ur textBox!
First u fill need 4 commands for Select/Update/Insert/Delete.
& As Microsoft recomended make 4 SPs in ur Datanbase (in MS-SQL)
Then fill ur dataset & [u]bind</u> ur controls & then when u updated ur controls cuz they r binded the Dataset will update so u will only need to call ur DataAdapter.Update() method!
& about inserts let me tell u by a simple sample.

Code:
DataRow anyRow = ExistingTable.NewRow();

anyRow[0] = "Jay";
anyRow[1] = "Stevens";

ExistingTable.Rows.Add(anyRow);
& Then call
Code:
DataAdapter.Update();
HTH, & plz keep in touch in every faced problem.

Always:),
Hovik Melkomian.
 
Old August 23rd, 2004, 06:08 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

although,you can ignore Microsoft recommendations! and instead of making four command just use a CommanBuilder object ,then dont worry about your queries CommanBuilder object sends them for you when you update your adapter.
(this method works only for one table).

--------------------------------------------
Mehdi.:)
 
Old August 25th, 2004, 03:40 PM
Registered User
 
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Keep in mind, the CommandBuilder is not 100% reliable for all platforms. If CommandBuilder is just not working, you may have to code your update statement manually.

 
Old August 25th, 2004, 04:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Um, do you have that Documented somewhere?

Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
 
Old August 25th, 2004, 05:23 PM
Registered User
 
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No, but when I did a search on the internet I found that lots of people were advising against using it for its unreliability. Plus I found with my own experience even though I did everything as recommended and explicity defined a primary key, it still returned a primary key not defined error.

So even though I am not completely sure I missed something, my several hours wasted trying to fix it combined with all the other people on the net saying how unreliable it is lead me to conclude it is not 100% reliable.

 
Old August 31st, 2004, 04:21 PM
Authorized User
 
Join Date: Jul 2004
Posts: 69
Thanks: 0
Thanked 1 Time in 1 Post
Default

I have been using the CommandBuilder for a while now and I have never had a problem . I use it every day. I have found it to be the quickest and easiest way.

www.CoderForRent.com
Get A Computer Job!





Similar Threads
Thread Thread Starter Forum Replies Last Post
inserting data into database using a jsp ronnie JSP Basics 4 January 15th, 2015 11:35 AM
Need help with inserting data into access database ITladybug ADO.NET 1 January 1st, 2006 01:50 PM
Inserting data into Access database OldCoder ASP.NET 2.0 Basics 1 December 31st, 2005 06:26 PM
inserting blob data into database taoufik Beginning PHP 2 November 19th, 2004 09:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.