| |

VerySource

 Forgot password?
 Register
Search
View: 610|Reply: 4

I would like to ask: how to dynamically create stored procedures in asp.net (C #)?

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-14 17:00:02
| Show all posts |Read mode
I know I can modify a stored procedure dynamically, but I don't know how to build a stored procedure dynamically?
Has anyone done it?

First post the code to modify the stored procedure as follows:

        string cStr = "Provider = Microsoft.Jet.OLEDB.4.0; Data source =" + Server.MapPath (DBPath);
        string ProcName;
        ADODB.Connection cn = new ADODB.Connection ();
        cn.Open (cStr, null, null, -1);

        // Activate and modify
        ADOX.Catalog catalog = new ADOX.Catalog ();
        catalog.ActiveConnection = cn;

        ADODB.Command cmd = new ADODB.Command ();
        cmd.CommandText = "PARAMETERS UserID varchar; select * from guestbook where username = UserID;";

        ADOX.Procedure pro = catalog.Procedures [ProcName];
        pro.Command = cmd;
Reply

Use magic Report

0

Threads

119

Posts

67.00

Credits

Newbie

Rank: 1

Credits
67.00

 China

Post time: 2020-6-11 21:15:01
| Show all posts
ExecuteNonQuery()
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-12 13:45:01
| Show all posts
It shouldn't be like yours. Look at this http://blog.csdn.net/net_lover/archive/2004/06/08/6963.aspx
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-13 17:15:01
| Show all posts
The following code can be created for practical use, but it is estimated that it is built in memory, and it is not visible in the query options of ACCESS.
The query entity named MyNewProName does not know how to move the stuff in memory to ACCESS.
Code:
//increase
string NewProName="MyNewProName";
ADODB.Command cmd1 = new ADODB.Command();
cmd1.CommandText = "PARAMETERS ArticleID long;select * from article where id=ArticleID;";

catalog.Procedures.Append(NewProName, cmd1);
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-19 16:15:01
| Show all posts
acidrain
   It shouldn't be like yours. Look at this http://blog.csdn.net/net_lover/archive/2004/06/08/6963.aspx
  
-----------------------
Thank you for your answer, but it still doesn't work. It's okay to build tables and libraries, but the stored procedure is different.
ADOX.Prucedure can't create a stored procedure object,
Such as: ADOX.Prucedure pro=new ADOX.Prucedure();
This will prompt an error.

Use this command: catalog.Procedures.Append(NewProName, cmd1);
It was executed, and a stored procedure was successfully added, but it was not seen in the query options of ACCESS.
depressed.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list