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 7th, 2005, 03:27 AM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Invoking Stored proc on Click of command button.

Hi,

Please can someone give me the code to execute a stored procedure by click of a command button ?
In Detail :
I have a combo box that displays all the online databases in a SQL server. I have a button "Backup" on my form.
When I choose one of the databases and click on the command button the chosen database needs to be backed up. I have the stored procedure which does the back up but not sure how to invoke it by click of the button.

Please help.

Thanks in Advance.
Vidya.

 
Old February 8th, 2005, 11:08 AM
Registered User
 
Join Date: Dec 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Write code likes this in the click event

'Declare connectionstring'
'Declare connection'

'Declare command-object like this'

Dim objcommand as new sqlcommand(or oledbcommand)
objcommand.commandtype= commandtype.storedprocedure

'connection open'

objcommand.executenonquery("name of stored procedure")

'connection close'

That should do it !

I suppose your procedure knows which of the databases to backup !
Otherwise we are talking about a stored procedure with a parameter, and that takes a litte more code.

Regards

Finn







Similar Threads
Thread Thread Starter Forum Replies Last Post
Error while invoking stored procedure in hibernate avinash_thm Hibernate 5 April 25th, 2007 03:46 AM
Calling an insert stored proc from a select stored dzitam SQL Language 10 April 2nd, 2007 12:39 PM
How to get value from stored proc busybee ASP.NET 1.0 and 1.1 Basics 4 April 2nd, 2006 01:06 AM
How i can OUTPUT in Stored Proc yoord SQL Server 2000 2 July 19th, 2004 03:11 PM
Invoking E-mail Client When Button Is Clicked Ben Horne Flash (all versions) 4 March 25th, 2004 10:06 PM





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