Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / May 2005

Tip: Looking for answers? Try searching our database.

Stored Procedure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sam - 31 May 2005 09:03 GMT
I want to convert standard SQL update syntax into calling stored procedure.

Normal Coding
-------------
Dim constr As String = "server='SQLSVR'; user id='USER';
password='password'; Database='ERP'"
Dim sqlcon As System.Data.SqlClient.sqlconnection = New
System.Data.SqlClient.sqlconnection(constr)
Dim sqlcmd As System.Data.SqlClient.SqlCommand = New SqlCommand()

sqlcmd.CommandText = "update F0411A set docnum = 0, doctype = ' ' where
docnum is null and doctype is null"

sqlcmd.Connection = sqlcon
Try
    sqlcon.Open()
    sqlcmd.ExecuteNonQuery()
Finally
    sqlcon.Close()
    sqlcon.Dispose()
End Try

constr = Nothing
sqlcmd = Nothing

Coding Calling Stored Procedure
-------------------------------
Try
    sqlcmd = sqlcon.CreateCommand
    sqlcmd.CommandText = "[Update_F0411A]"
    sqlcmd.CommandType = CommandType.StoredProcedure
Finally
    sqlcon.Close()
    sqlcon.Dispose()
End Try

Stored Procedure
----------------
Create Procedure "Update_F0411A" as
update F0411A set docnum = 0,
      doctype = ' '
where docnum is null and doctype is null

Please advise the coding whether I do correctly or not.

Many thanks.
Cowboy (Gregory A. Beamer) - MVP - 31 May 2005 15:29 GMT
It looks fine to me. Since you do not have procedure parameters, simply
moving the SQL statement into the stored proc should work, as you have done.

Signature

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

> I want to convert standard SQL update syntax into calling stored procedure.
>
[quoted text clipped - 42 lines]
>
> Many thanks.
Thor Kornbrek - 01 Jun 2005 00:22 GMT
You would need to call one of the execute methods still, ExecuteNonQuery
since this returns no rows.

I do not see that in your new routine.

This is where I found documentaion on the matter.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fsystemdatasqlclientsqlcommandclasscommandtypetopic.asp

Signature

Thor Kornbrek
.Net Developer

> I want to convert standard SQL update syntax into calling stored procedure.
>
[quoted text clipped - 42 lines]
>
> Many thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.