By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,087 Members | 1,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,087 IT Pros & Developers. It's quick & easy.

A desperate help in Update

P: n/a
Hello! Experts,

I have the following piece of code in VB.NET that I want to use to
update any records in the database. I would like to use a code as well
as DataGrid to update the records. Please guide me how can I achieve
it. I know there is an Update command to to do this that but since I
am a newbie I don't know how? I'll be really grateful to those who may
help me buy modifying the following code. I am really desperately
looking for your help. I know this will only take a fraction of your
time but it will be a very big help for me. Thanks to all...

------------------------------------------------------------------------
Private odbcAd As New Microsoft.Data.Odbc.OdbcDataAdapter
Private Conn As New Microsoft.Data.Odbc.OdbcConnection
Private ds As New DataSet("AnyTable")

Conn.ConnectionString = "DSN=TestDSN"

Conn.Open()

Dim SQL As String
SQL = "SELECT * FROM AnyTable"

odbcAd = New Microsoft.Data.Odbc.OdbcDataAdapter(SQL, Conn)

ds.Clear()

odbcAd.Fill(ds, "AnyTable")

DataGrid1.SetDataBinding(ds, "AnyTable")

ds.Tables("AnyTable").Rows(1).Item(3) = "Test"
------------------------------------------------------------
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hello -

You need to call the Update method of your DataAdapter. Check out this help
topic:

Updating a Data Source with a Dataset (Visual Basic and Visual C# Concepts)
http://msdn.microsoft.com/library/en...mingUpdates.as
p
hope that helps
Steve Stein
VB Team

This posting is provided "AS IS" with no warranties and confers no rights.

--------------------
From: sa*********@yahoo.com (Sajid)
Newsgroups: microsoft.public.dotnet.languages.vb.data,microsof t.public.dotnet.languages.
vbSubject: A desperate help in Update
Date: 27 Jan 2004 11:18:46 -0800
Organization: http://groups.google.com
Lines: 33
Message-ID: <e0**************************@posting.google.com >
NNTP-Posting-Host: 195.13.97.12
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1075231126 22381 127.0.0.1 (27 Jan 2004 19:18:46 GMT)X-Complaints-To: gr**********@google.com
NNTP-Posting-Date: Tue, 27 Jan 2004 19:18:46 +0000 (UTC)
Path: cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!news-out.cwix
..com!newsfeed.cwix.com!news.maxwell.syr.edu!postn ews1.google.com!not-for-mai
lXref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.vb:176578 microsoft.public.dotnet.languages.vb.data:2998X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hello! Experts,

I have the following piece of code in VB.NET that I want to use to
update any records in the database. I would like to use a code as well
as DataGrid to update the records. Please guide me how can I achieve
it. I know there is an Update command to to do this that but since I
am a newbie I don't know how? I'll be really grateful to those who may
help me buy modifying the following code. I am really desperately
looking for your help. I know this will only take a fraction of your
time but it will be a very big help for me. Thanks to all...

------------------------------------------------------------------------
Private odbcAd As New Microsoft.Data.Odbc.OdbcDataAdapter
Private Conn As New Microsoft.Data.Odbc.OdbcConnection
Private ds As New DataSet("AnyTable")

Conn.ConnectionString = "DSN=TestDSN"

Conn.Open()

Dim SQL As String
SQL = "SELECT * FROM AnyTable"

odbcAd = New Microsoft.Data.Odbc.OdbcDataAdapter(SQL, Conn)

ds.Clear()

odbcAd.Fill(ds, "AnyTable")

DataGrid1.SetDataBinding(ds, "AnyTable")

ds.Tables("AnyTable").Rows(1).Item(3) = "Test"
------------------------------------------------------------


Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.