Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2004, 05:43 AM
Authorized User
 
Join Date: Aug 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Alcapone
Default Check before insert data into sql

Hi,

Am creating an application that hold information about trainees and there progress. I have a table that holds the total amount of points a trainee has. A teacher can update the trainees info by selecting the course the trainee has followed only i need to build in a error handeling that checks if the teacher insn't inserting dubble values.

Example in T-sql:

insert into dbo.StudyPoints (Study_uno, Points, Type, Gedoceerd, CrsDate, Trainee_uno)
Select Study_uno, 3, Type, 'Y', '27-10-2004', (Select Trainee_uno from Trainees where lastname like '%Pietje%' and Firstname like '%Puk%') from Course where name like '%Test A%'

but before i do this insert i need to check if the all ready is something in the database with these values...cann some one tell me how??

Regards,
Martijn
 
Old October 26th, 2004, 06:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Just do a select to see if the data exists; you can do this many ways, one is:

Declare @check bit

select @check = 1 from Course where ... provide where clauses ...

Brian
 
Old October 26th, 2004, 07:57 AM
Authorized User
 
Join Date: Aug 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Alcapone
Default

Thank you Brian for your reply. It works now, thanks.





Similar Threads
Thread Thread Starter Forum Replies Last Post
check box data insert error mateenmohd Classic ASP Basics 3 May 28th, 2007 05:29 AM
insert form data in an sql and email the content ddnk77872 PHP Databases 3 February 13th, 2007 09:47 AM
INSERT Data to SQL Database Lofa ASP.NET 1.0 and 1.1 Basics 1 February 22nd, 2006 03:09 AM
Insert data in SQL ASP .NET 2.0. alexsaiz82 ASP.NET 2.0 Basics 0 January 3rd, 2006 03:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.