You are here: Re: Saving data to SQL Data Base « MsSQL Server « IT news, forums, messages
Re: Saving data to SQL Data Base

Posted by Dan Guzman on 08/13/07 11:38

> Thanks I know that i must use an Update command.
> But i'm programming in compiling time, i can't use the VS data base
> tool to generate update command

You can create your own UpdateCommand manually. Be sure to specify all
columns that were returned by the SelectCommand.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Omar Abid" <omar.abid2006@gmail.com> wrote in message
news:1186914886.560453.106490@r34g2000hsd.googlegroups.com...
> On Aug 10, 5:36 am, "Dan Guzman" <guzma...@nospam-
> online.sbcglobal.net> wrote:
>> > but now i want to save the changes in the table (after making
>> > modifications in the dgv)
>> > i use : dta.update(dt)
>> > but that don't work !!!!!!
>>
>> You need to set the SqlDataAdapter.UpdateCommand property. The UPDATE
>> command (as well as INSERT and DELETE) can be auto-generated if primary
>> key
>> information can be derived from the SelectCommand and you use a
>> SqlCommandBuilder. See the VS documentation for details and examples.
>>
>> Also, I suggest you consider using stored procedures for data access and
>> modification. Procs are more secure and promote execution plan re-use.
>>
>> --
>> Hope this helps.
>>
>> Dan Guzman
>> SQL Server MVP
>>
>> "Omar Abid" <omar.abid2...@gmail.com> wrote in message
>>
>> news:1186747639.036460.260430@m37g2000prh.googlegroups.com...
>>
>> > Hi,
>> > I'm using the following code to open a data base and show it's content
>> > in a Data Grid View
>> > ----
>> > Code
>> > -----
>> > Imports System.Data.SqlClient
>>
>> > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
>> > System.EventArgs) Handles MyBase.Load
>>
>> > Dim conn As New SqlConnection("Data
>> > Source=./wideserver;Path="c:/cct.mdf";User
>> > Id=username;Password=Password;")
>> > Using (conn)
>> > conn.Open()
>> > Dim com As SqlCommand = conn.CreateCommand()
>> > Using (com)
>> > com.CommandType = CommandType.Text
>>
>> > com.CommandText = "Select * From users"
>> > Dim da As New SqlDataAdapter(com)
>> > Using (da)
>> > Dim dt As New DataTable("usertable")
>> > Using (dt)
>> > da.Fill(dt)
>> > Dim dgv As New DataGridView()
>> > dgv.Dock = DockStyle.Fill
>> > dgv.DataSource = dt
>> > Me.Controls.Add(dgv)
>> > End Using
>> > End Using
>> > End Using
>> > End Using
>> > End Sub
>> > -----
>> > end code
>> > -----
>>
>> > The following code allow me to see the table data in a Data Grid View
>> > but now i want to save the changes in the table (after making
>> > modifications in the dgv)
>> > i use : dta.update(dt)
>> > but that don't work !!!!!!
>> > Any Help and thanks a lot
>> > Omar Abid
>> >www.omarabid.uni.cc
>
> Hi,
> Thanks I know that i must use an Update command.
> But i'm programming in compiling time, i can't use the VS data base
> tool to generate update command
> Omar Abid
> www.omarabid.uni.cc
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация