473,666 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic MSSQL results, DataGridViews and changes

6 New Member
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 1340
kenobewan
4,871 Recognized Expert Specialist
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
2192
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 not use mysql or anyother one that are not *authorize*, it's oracle or mssql. Now we have to make it work also with our sun and HP unix server(plus one Linux). So I propose to use python, and after they see my litle python/wxwindow program, that...
8
2826
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 boxes and saving to the database at the end with the 'Submit' command button. Is it possible to save the changes as the checkboxes are clicked? I suppose I'd need to write some dynamic ASP event handling at the same time as creating the checkboxes......
15
5170
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 content of a sp; and b) using bcp to write such content to a (dynamic) file. What bugs me is really the curse of dynamic sql. process inside a cursor: ------------------------ exec master..xp_cmdshell 'bcp "exec sp_helptext '+@spName+'" queryout
3
2932
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 groups for years, I figure it's time for me to contribute a little bit back, maybe some people out there will find this useful. * Introduction This is a "how-to" style article, showing by example how to dynamically
0
1370
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 the standard way. Whenever the parent record changes, the data displayed in the child DataGridView changes appropriately. However the first record in the child DataGridView is always highlighted as the 'current record' and I would like to have...
13
17135
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 launching Excel for data viewing. I'd prefer the user stay in Access. Creating dynamic crosstab queries is pretty simple. The problem is that the column count may shrink or grow depending on the filter.
5
3162
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 querying a database, negotiatinig lots of if-then-else logic and echo'ing html code out on port 80 every time a page is requested has to be a huge waste of resources. Why not use that logic to print static html instead of dynamic?
14
2920
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 MSSQL 2k (SP4) on server 2 (using ASP). I can load a basic 'Hellow world' PHP page hosted on server1 but when I add the code to create a simple connection to MSSQL on server 2, my PHP doesn't seem to connect nor output any of the desired query...
3
2106
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 code into the mssql statement that says 'If the current date is the friday before the event date, and the event date is on a saturday or sunday, then dont show that event' when I run that code in mssql it returns the correct results - when its firday...
0
8438
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
8348
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8863
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...
1
8549
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
7376
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...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1761
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.