我正在尝试从存储过程中获取值,下面是我的代码SqlConnection connection = new SqlConnection("");connection.Open();DataTable timeZoneDt = new DataTable();var sqlCommand = new SqlCommand("GetTimeZoneGMT", connection);sqlCommand.CommandType = CommandType.StoredProcedure;sqlCommand.Parameters.Add("@TimeZone", SqlDbType.NVarChar).Value = "Asia/Kuala_Lumpur";//timeZoneDt.Load(sqlCommand.ExecuteReader());//new SqlDataAdapter(sqlCommand).Fill(timeZoneDt);var reader2 = sqlCommand.ExecuteReader();while (reader2.Read()){ var ID = int.Parse(reader2[0].ToString());}connection.Close();以下是我的存储过程,/****** Object: StoredProcedure [dbo].[GetTimeZoneGMT] Script Date: 23/4/2018 4:05:46 PM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[GetTimeZoneGMT] @TimeZone NVARCHAR(128)ASBEGIN DECLARE @timeZoneNumber as INT = -20; IF @TimeZone ='Pacific/Midway' SET @timeZoneNumber = -11 ELSE IF @TimeZone ='Pacific/Niue' SET @timeZoneNumber = -11 ELSE IF @TimeZone ='Pacific/Pago_Pago' SET @timeZoneNumber = -11 RETURN @timeZoneNumber;END我不能全部写给大家,因为时区有400行,但是类似。但是,当我得到我的C#代码时,它是空值,为什么呢?代码有什么问题
1 回答
- 1 回答
- 0 关注
- 134 浏览
添加回答
举报
0/150
提交
取消