Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 7th, 2008, 03:54 AM
Authorized User
Points: 493, Level: 7
Points: 493, Level: 7 Points: 493, Level: 7 Points: 493, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2006
Location: gandhinagar, gujarat, India.
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB problem

hi all

I have one application in vb with database access.I have one table in access as emp_mast.I have so many records in emp_mast.Now i add one field "printdate" in emp_mast.i fire insert query like:

Private Sub printdata()
Dim strsql As String
Dim temprs As New ADODB.Recordset
Dim datestr As Date

datestr = dtpdate.Value

strsql = "insert into Emp_Mast(printdate) values(" & datestr & ") where Middle_Name='" & cmbName.Text & "'"

temprs.Open strsql, cn
MsgBox "record saved"
End Sub

this code is not run successfully,when i see database there is no record in emp_mast.

so what is exctally problem? i am not getting
pls help me


Reply With Quote
  #2 (permalink)  
Old July 7th, 2008, 07:40 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi

Hi there.
You are using a recordset to execute a insert query, that's the problem...

to do that just use cn.execute (if cn is your connection).



================================================== =========
Read this if you want to know how to get a correct reply for your question:
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
================================================== =========
I know that CVS was evil, and now i got the proof:
================================================== =========
Reply With Quote
  #3 (permalink)  
Old July 8th, 2008, 03:29 PM
Friend of Wrox
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts

"SET PRINTDATE = " & datestr & " " & _
"WHERE MIDDLE_NAME = '" & cmbName.Text & "'"

Not "Insert."

Insertions are unqualifed. Using WHERE . . . indicates you are trying to fill one of the fields of a record with values matching the WHERE clause.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in VB.NET? bhavna VS.NET 2002/2003 0 January 22nd, 2007 07:48 AM
Small problem VB (thanks!) kris5 VB How-To 2 November 27th, 2006 12:11 PM
VB 6.0 Printing problem gingira Beginning VB 6 9 January 19th, 2005 07:28 AM
problem in VB datareport a_nasikkar Pro VB Databases 0 September 3rd, 2004 10:19 AM
Problem with eMbedded VB sporkman43 VBScript 0 March 24th, 2004 02:07 PM

All times are GMT -4. The time now is 05:17 PM.

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