Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics 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 February 2nd, 2005, 12:24 PM
Authorized User
 
Join Date: May 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to haron_Master Send a message via AIM to haron_Master Send a message via MSN to haron_Master Send a message via Yahoo to haron_Master
Default Syntax Problem Please i need your help

Here is my Code i'm a beginner,when i run the command it gives me a syntax error after that i delete the rows and not transfer to the other record thanks any can help me.

    If Mode = "AddTransfer" Then
     msg = MsgBox("Are you sure you want To Save your Files", vbYesNo)
     If msg = vbYes Then
      srchPrprty = "Property = " & Val(Text4(2))
      If srchPrprty = rstNew!Property Then
   strSQL = "Delete * from NewProperty "
   strSQL = strSQL & " where Property = '" & Val(Text4(2)) & "' And Dptcode = '" & Val(Text4(0)) & "' And "
  strSQL = strSQL & "Insert Into Newproperty (dptcode,dptname,dater,reason,number,Description,M anufacturer,Model,Se rialnumber,Status,Property)"
strSQL = strSQL & "values('" & Val(Text4(3)) & "','" _
 & Text4(6) & "','" _
                                & MaskEdBox3 & "','" _
                                & Text4(7) & "','" _
                                & Val(Transfer.TextMatrix(Transfer.Row, 1)) & "','" _
                                & Transfer.TextMatrix(Transfer.Row, 2) & "','" _
                                & Transfer.TextMatrix(Transfer.Row, 3) & "','" _
                                & Transfer.TextMatrix(Transfer.Row, 4) & "','" _
                                & Transfer.TextMatrix(Transfer.Row, 5) & "','" _
                                & Transfer.TextMatrix(Transfer.Row, 6) & "','" _
                                & Val(Transfer.TextMatrix(Transfer.Row, 7)) & "')"
                        dbs.Execute strSQL, dbFailOnError





none
__________________
none
 
Old February 2nd, 2005, 01:08 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

But in the code u are inserting the records, right

on which line u are getting error & what is the error?

Om Prakash
 
Old February 2nd, 2005, 01:33 PM
Authorized User
 
Join Date: May 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to haron_Master Send a message via AIM to haron_Master Send a message via MSN to haron_Master Send a message via Yahoo to haron_Master
Default

IT GIVES ME A MESSAGE THAT I HAVE A DUPLICATE VALUE ON MY PRIMARY KEY ON THE LINE OF dbs.Execute strSQL, dbFailOnError



none
 
Old February 2nd, 2005, 01:45 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

SO U CAN CHECK FOR THE EXISTANCE OF RECORD BEFORE INSERTING.

I guess the primary key is dptcode. so before inserting the data, check if data is already present for that code ot not.

Hope this helps..

Om Prakash
 
Old February 2nd, 2005, 01:56 PM
Authorized User
 
Join Date: May 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to haron_Master Send a message via AIM to haron_Master Send a message via MSN to haron_Master Send a message via Yahoo to haron_Master
Default

Thanks i would try

none





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with syntax MarkMingLuy ASP.NET 1.0 and 1.1 Basics 1 November 30th, 2006 07:42 AM
syntax problem with SQL nancy SQL Server 2000 4 May 6th, 2005 12:56 PM
xpath syntax problem nrane26 XSLT 1 January 22nd, 2005 01:25 PM
Query syntax problem mateenmohd Access 2 October 12th, 2004 11:33 PM





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