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

Dynamic MSSQL results, DataGridViews and changes

Hello everyone,
It would appear I'm trying to do something that's completely undocumented. I can't find anything of any use online to help me with this...

I'm working on developing an MSSQL query editor for a bigger database program, for a university project. The project consists of around 50 or so tables. The query editor is meant to display a tabcontrol with a text box for query input on each tab, and a Datagridview, to display the resultset from the query(s).
Multiple tabs allow the user to compare the results of two or more queries (I have 5 tabs, and 5 datagridviews for the 5 textboxes on those tabs).

I'm having issues when it comes to saving new rows added to the resultset displayed in my datagridview. If I select a table that contains a primary key, the primary key information is lost, so when I save the changes made in the datagridview, I get exceptions about my primary key field being read only.

The problem would be a lot simpler if I was doing constant queries, but becauss the program must be able to execute any query the user gives it, it needs to be able to understand if a field in the resultset is a primary key.

Hopefully I've explained my problem cleary. Suggestions/Ideas anyone? They'd be most appreciated. :)
Jan 9 '07 #1
1 1329
kenobewan
4,871 Expert 4TB
Tricky problem - there are two parts as far as I can see - error handling and ensuring that the datagridview is updated so that the primary key does not generate an error.

You could modify this for the error handling:
Expand|Select|Wrap|Line Numbers
  1. Sub GridViewUpdated(ByVal s As Object, ByVal e As GridViewUpdatedEventArgs)
  2.         If Not e.Exception Is Nothing Then
  3.             lblError.Text = "Could not update row"
  4.             e.ExceptionHandled = True
  5.         End If
  6.     End Sub
For the updating are you displaying the primary key in the datagridview? It should be ready only so that it can't be changed. If you are trying to set the primary key in the update instead of using it in the where... Please provide more details re this.
Jan 10 '07 #2

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

Similar topics

3
by: francisl | last post by:
We have to build some script were I work to make a dynamic server inventory. But, the project team, a windows crew, start it all in vbscript and on mssql. Note, due to political reason, we can...
8
by: DylanM | last post by:
I have some checkboxes that are generated from the results of a database search. At the moment, the checkboxes are part of a table making up a form. Users are going through the form, clicking the...
15
by: NickName | last post by:
Task: Create 100 or so stored procedure scripts similar to the convention of Generating Script from EM automatically. I thought of essentially two things of a) using sp_helptext to get the...
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
0
by: Susan Mackay | last post by:
I have an application that works well, with two DataGridViews connected with the necessary BindingSources, DataTables etc to have one DataGridView act as the parent and the other as the child in...
13
by: salad | last post by:
Operating in A97. I didn't receive much of a response conserning Pivot tables in Access. Pivot tables are nice, but a CrossTab will work for me too. Using a Pivot table, one is actually...
5
by: pittendrigh | last post by:
There must be millions of dynamically generated html pages out there now, built by on-the-fly php code (and jsp, perl cgi, asp, etc). Programatic page generation is transparently useful. But...
14
by: guswebb | last post by:
Hi. I'm a newbie to PHP and am having a few problems as follows... I have installed PHP successfully on server 1 which is running IIS 6 (W2k3) and hosting multiple sites, some of which connect to...
3
by: tiptap | last post by:
Hey, I have a really confusing problem here. I'm using MSSQL & PHP. I have created a querry in MSSQL that basically shows a list of events and shows them in date order. I have written a bit of...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...

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.