Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can i create the stored procedures in vb.net?
Message
 
 
To
28/09/2011 06:19:42
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01525020
Message ID:
01525031
Views:
53
>Hi all,
> I use vb.net. I want to create table, so i go to sql server management studio to generate scripts (generate create table ).
>After i want to create the stored procedures by code. But i don't know how can i do.
>And i try the below code , but i don't know why error and this is right method.
>Anyone can give some information to me, thank you ~~~
>
>
>
>  Dim nDatabase As New SQLDMO.Database()
>
>                    Dim strProc As New SQLDMO.StoredProcedure()
>                    strProc.Name = "Sp_CreateTableCompany"
>                    strProc.Text = "CREATE procedure InsEmployees(" & _
>        "@v_EmpNo int,@v_Name varchar(50),@v_Surname varchar(50)," & _
>         "@v_isPermanent char(10))" & _
>         "as " & _
>        "Begin Insert Into PersonalInfo(EmpNo,Name,Surname,isPermanent)" & _
>        "values (@v_EmpNo,@v_Name,@v_Surname ,@v_isPermanent) end"
>
>                    nDatabase.StoredProcedures.Add(strProc)
>
First problem I see right away is that the name of your SP does not match the name in code. It should be InsEmployees. BTW, never start naming procedures with sp_ unless you want to create a system stored procedure.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform