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

How to Use DatagridView Columns in Update Query

Hi,
My application is in VS2008 coded in VB.Net
I have a DatagridView.I have a Save Button on my Form.Now my requirement is i want to Update the Data that is populated in Datagridview when i click on Save button.
I want to do it using Update Query.
below is my code.
DgvStudRecord is my DatagridView
I want to update only the Fourth Column in Datagrid.
Expand|Select|Wrap|Line Numbers
  1.   Sub update()
  2.         DBConnect()
  3.         con = DBActions.DBConnect
  4.         strsql = "Update AdmittedStudents set MobileNo='"  DgvStudRecord.Item(4,    DgvStudRecord.CurrentCell.RowIndex)  "' where RegNo='" & 1 & "'"
  5.         cmd = New SqlCommand(strsql, con)
  6.         cmd.ExecuteNonQuery()
  7.         MessageBox.Show("Record Updated", "Weekly Off",         MessageBoxButtons.OK)
  8.     End Sub
  9.  
Im getting an error in the Query as End Of Statement Expected.This is the first time transacting using DatagridView.
Please suggest at the earliest where im wrong.
Sep 7 '11 #1
0 1141

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Alex | last post by:
Hello, I have a rather large table in MS SQL 2000 that I'm writing reports in Crystal from, but I'm unsure how to get the various data files (from different departments) into the table. Below...
3
by: Paul Cheetham | last post by:
Hi, I have a DataGridView control, and I am using it's datasource property to assign a datatable to it at runtime. The datatable has some columns in it that I don't want to be visible. With...
5
by: colleen1980 | last post by:
Hi: In my table there is a field of type checkbox. I create a button on my form and wants to deselect all the checkboxes in that field (PrintQueue). Table: Research_New PrintQueue Format Yes/No...
0
by: Spam Catcher | last post by:
Is it possible to assign DAtaGridView Columns to subproperties, for example: MyObject.SomeProperty.ValueToBind I can only assign 1st level properties, but not child ones?
0
by: anureddy | last post by:
help me how to add datagridview columns to another table,using windowsapplications. and set the displaymember and value member datagridviewcomboboxcolumn. i used this below code but that not...
8
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
If I populate a DataGridView with a query supplied at runtime, boolean fields render as a CheckBox instead of just a text rendering of '0' or '1'. That is nice sometimes, but I would like the...
13
by: Neil | last post by:
I'm running an update query in SQL 7 from QA, and it runs forever. Has been running for 20 minutes so far! The query is quite simple: update a single field in a table, based on a join with another...
5
by: Chris Kennedy | last post by:
Hi all I'm running SQL Server 2005 Express Edition. One database One table called Sites Fields as follows: id (bigint, Identity, Primary Key) SiteName (varchar(50), allows nulls) Generation...
2
by: Oleg Subachev | last post by:
I have DataGridView which DataSource is assigned to Table<> object of DataContext connected to SQL Server database. But when the underlying SQL Server database is updated (through ODBC...
1
by: islandgal | last post by:
-- -- Table structure for table borrower -- DROP TABLE IF EXISTS borrower; CREATE TABLE borrower ( brw_num int(11) NOT NULL default '0', brw_lname varchar(15) default NULL, brw_fname...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.