Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-12-06 : 11:07:09
|
| I have another one that I'm trying to understand in the Try section. What is the bold part means/says?Dim sqlConnection3 As New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("PendingClaimsConnectionString").ConnectionString) Dim cmd3 As New SqlCommand cmd3.Connection = sqlConnection3 cmd3.CommandText = "PCSelectDoc" cmd3.CommandType = System.Data.CommandType.StoredProcedure cmd3.Parameters.AddWithValue("@Doc", Request.QueryString("doc")) Try cmd3.Connection.Open() cnt = Convert.ToInt32(cmd3.ExecuteScalar()) If (cnt = 1) Then ElseIf (cnt = 0) Then Response.Redirect("Errors.aspx?doc=" & Session("doc")) End If Catch exc As SqlException Response.Redirect("Errors.aspx?doc=" & Session("doc")) Finally cmd3.Connection.Close() End TryHere's the stored procedure for PCSelectDocALTER Procedure [dbo].[PCSelectDoc] --'113'@Doc char(3) ASselect count(*) as cntFROM Offices.dbo.OfficeCodes WHERE OfficeCode = @Doc |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-12-06 : 11:10:05
|
cnt is a local variable that is used to store the returning number from cmd execution. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-12-06 : 11:17:15
|
| Thanks Peso. What does this mean?cnt = Convert.ToInt32(cmd3.ExecuteScalar()) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-12-06 : 14:03:58
|
cmd3 is your command object which has a CommandText property.You call the ExecuteScalar method to execute the comnmand text and ensure that the only thing returned is a scalar value.Then you convert the return value from CommandText into a 32-bit integer to you cnt local variable. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-12-06 : 20:03:39
|
Thanks Peso! |
 |
|
|
|
|
|