Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Running stored procedures/copying results in VB.net
Message
From
21/09/2011 14:21:57
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01524129
Message ID:
01524186
Views:
41
>>>>
SQLCon.ConnectionString = "Data Source=server;Initial Catalog=database;Integrated Security = True;"
>>>>        SQLCon.Open()
>>>>        SQLCmd = New SqlCommand("StandardNamesUpdate", SQLCon)
>>>>        SQLCmd.CommandType = CommandType.StoredProcedure
>>>>        SQLCmd.ExecuteNonQuery()
>>>>        SQLCon.Close()
>>>>
>>>>
>>>>When I run the program it pauses about as long as it takes for the SP to run in SQL Server, and then my e-mail is generated so it may be working. Now I need a way to check to see if it's working for sure, can I assign it to a text box and have it show me the number of rows affected? After that, how do I get it to copy the results of the second SP so I can have it pasted into the e-mail?
>>>
>>>You may want to do a bit more reading on ADO.NET methods and go through examples in MSDN. I made another quick Bing search, found this link that provides more links - you may want to start from them
>>>http://wonald.com/ado-net-performance-executereader-vs-executenonquery-vs-executescalar-93.htm
>>
>>Well I found out my code is working for the update SP, it shows me the same number of affected rows as when I run the SP manually. Now all I need to do is run the second SP so that it's able to be copied like the grid view in SQL Server... I looked at your link but didn't find any examples for that, partly because I don't know exactly what it's called.
>>
>>Can you control that stuff in VB? Have it output to some sort of unseen gridview and then copy it?
>
>To get result as dataset you can use two main methods - first is to ExecuteReader (this was in my link - I put comparision between 3 main methods) and second approach is to create dataset and use its Fill method to fill it with data.
>
>Start from reading on ExecuteReader.

That I did read and I used that in the code:
SQLCmd = New SqlCommand("StandardNamesCount", SQLCon)
        SQLCmd.CommandType = CommandType.StoredProcedure
        SQLCmd.ExecuteReader()
But that's when I couldn't figure out how to copy it to the clipboard from there, or if it would even copy in a gridview type style like I'm trying to do.

Then I also did the gridview method and had it fill, but again, no idea how to copy the contents from there.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform