Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
|
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 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 December 15th, 2008, 11:02 AM
Authorized User
 
Join Date: Feb 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Angry Sql-Server VB 2005 not able to update DB

Windows XP
VB 2005 Pro
SQL Server 2005 and SQL server management studio 2005 express

I have created a series of programs using a simple Access database. these programs used OLEDB and SQL, all worked fine.

Now I am trying to re-write the programs using SQL server.
my connections string:
"Data Source=computername\SQLEXPRESS;Initial Catalog=SQLfeedback;Integrated Security=True;"
I can read all and locate records fine. However when I try to change a record I get a problem.
Trace info from debug write and output window.
SQL string:
SQL = UPDATE (feedback) SET anemail = '[email protected]' WHERE (id = 1)
Errors:
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll Incorrect syntax near '('.

The SQL string is similar (only table and item names are different) to the OLEDB version which works.
I changed all the OLEDB class methods to SqlClient class methods also checked my connection string to a SQL server wizard version of the program that worked and updated and the string was the same.

Any ideas where to look next?
__________________
Pat
 
Old December 15th, 2008, 03:19 PM
Authorized User
 
Join Date: Feb 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default More info

I have tried insert and delete programs and these work - so this has to be a stupid error.

The program:-
  1. User types in selection criteria
  2. Program locates any record or records that fit criteria these are displayed.
  3. Connection closed and disposed.
  4. User selectes record to be updated and suppies new values and selects update button.
  5. Program user key of record to be changed and new values to create sql string.
  6. Connect to database sqlsconnection open database
  7. create myCommand new sqlcommand using sqlstring and sqlsconnection
  8. myCommand.ExecuteNonQuery()
I think it must be the SQL string ot the connection string since the sql string looks fine that leaves the connection string but what do I need for update that is not needed for insert or delete?
__________________
Pat
 
Old December 15th, 2008, 04:57 PM
Authorized User
 
Join Date: Feb 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Knew it was simple

I changed the SQL string to
UPDATE feedback SET anemail = '[email protected]' WHERE id = 1

seems SQL server is more fussy than OLEDB with SQL string syntax.


__________________
Pat





Similar Threads
Thread Thread Starter Forum Replies Last Post
reg conn to sql server 2005 from vb.net 2005.. veda SQL Server 2005 2 July 1st, 2008 12:16 AM
Insert/Update to sql server DB in a scheduler rajanikrishna ASP.NET 2.0 Professional 3 October 26th, 2007 04:27 AM
can't access db in sql server 2005 brillox BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 3 May 3rd, 2007 05:15 PM
VB 2005 connect to server 2003 with SQL database Derek_05 Visual Basic 2005 Basics 3 September 20th, 2006 10:10 AM
Moving db to SQL Server 2005 for deployment LoneStar1 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 4 March 3rd, 2006 01:52 PM





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