Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can i create the stored procedures in vb.net?
Message
 
 
À
28/09/2011 06:19:42
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01525020
Message ID:
01525031
Vues:
52
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform