473,787 Members | 2,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Use DatagridView Columns in Update Query

45 New Member
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 1175

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

Similar topics

2
5799
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 is a small chunk of the table: DeptCode;Type;AveMonthVolume;WorkedFTE;TotHours;Benefits I'm getting data from multiple places, but as I import the data, I
3
2873
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 the DataGrid control in .Net 1, each Column had a property that allowed it to be bound to a column in a datatable, so I could define the columns of the grid, and which columns they related to in its datasource, and they were all that would display.
5
2999
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 Thanks for help.
0
808
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
1657
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 exicute. how can i write that code. pls send me code.
8
9032
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 flexibility of showing text sometimes as well. Is there an easy way to get the text '0' or '1' instead of the CheckBox? My DataGridView is filled in with this basic code: DataTable dataTable = new DataTable(); qBindingSource.DataSource = dataTable;...
13
4177
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 table. There are a total of 1200 rows that are affected (out of a total of 60,000 in the table). Should not take 20 minutes! Also, retrieving the 1200 rows using the same criteria is instantaneous. Anyone have any idea what's going on? Here's...
5
5493
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 (float) LastUpdated (varchar(50), allows nulls)
2
3933
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 connection) the DataGridView is not updated. I see that Table<is updated because its Count is changed. How to force DataGridView to update itself in such situation ?
1
1442
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 varchar(15) default NULL, brw_initial varchar(1) default NULL, brw_areacode varchar(3) default NULL,
0
9655
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
10363
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
10172
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
10110
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
9964
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
8993
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...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.