Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 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 November 18th, 2013, 08:51 AM
Authorized User
 
Join Date: Sep 2011
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default VB 6 Verification, sql insert

Hi

I have this code below:

Set cnHPtest = New ADODB.Connection

With cnHPtest
.Provider = strDBProv
.ConnectionString = strDBString
.CommandTimeout = 1000
.Open
End With

'If txtSalary.Text <> " " And txtmCover <> " " And txtMember.Text <> " " And txtmRate.Text <> " " Then

' MsgBox "Welcome"

tsql = "INSERT INTO Hpacc4(SalaryBill,Rate,Membership,Cover) " & _
"VALUES('" & txtSalary.Text & "','" & txtmCover & "', '" & txtMember.Text & "', '" & txtmRate.Text & "')" & _
"WHERE Scheme = '99993' AND RunMonth = '200604' AND AccCode = '110'"

cnHPtest.Execute (tsql)

'Else
' MsgBox "Enter Values"
'End If

I have of problems with this code.

1. When I run only the inner part of it:
tsql = "INSERT INTO Hpacc4(SalaryBill,Rate,Membership,Cover) " & _
"VALUES('" & txtSalary.Text & "','" & txtmCover & "', '" & txtMember.Text & "', '" & txtmRate.Text & "')" & _
"WHERE Scheme = '99993' AND RunMonth = '200604' AND AccCode = '110'"

I get and error that there is a problem with my where clause, which would mean I didn't write the code correctly, please help.

2. when I un-comment the whole code and try to run, my verification fails, I always get MsgBox "Welcome" even when my text fields are empty





Similar Threads
Thread Thread Starter Forum Replies Last Post
vb.net sql autonumber insert GIGAM25 SQL Language 1 July 10th, 2008 01:10 AM
How to insert a Picture in SQL Server using VB 6.0 swadhinm Pro VB Databases 0 September 21st, 2005 06:52 AM
Email verification John K. King Javascript How-To 4 November 24th, 2004 03:59 AM





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