I need to get the title (report name) from a stored procedure in VB, but I have variable name “title” which need to use that stored procedure in order to get that title. How should I do this?
Also the output of the stored procedure has spaces which I need to remove in VB code.
The variable looks like this:
Dim title as string = 'titlereportname_' & Format(Now(), "M-d-yy")
How should I make that title not to be hard coded but come from the stored procedure?
I got the following connection:
Dim dt As DataTable
Dim conn As New SqlClient.SqlConnection()
Dim command As New SqlClient.SqlCommand
dt = New DataTable
conn = new SqlClient.SqlConnection(DataProvider.connectionstring(sDatabaseAlias))
conn.Open()
command = New SqlClient.SqlCommand
command.CommandType.Text
command.CommandText = "GetReportTitle"
command.Parameters.AddWithValue("@ProjectName", sProject)
command.Parameters.AddWithValue("@Link", sLink)
command.Connection = conn
dt.Load(command.ExecuteReader())
command.Dispose()
conn.Close()
conn.Dispose()
This line is nonsensical:
command.CommandType.Text
You need to set the CommandType
property. It is set to CommandType.Text
by default, which means that your CommandText
is assumed to contain SQL code. If it actually contains the name of a stored procedure then you need to do this:
command.CommandType = CommandType.StoredProcedure
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.