ALTER PROCEDURE [dbo].[InsertSMS]
-- Add the parameters for the stored procedure here
@SmsMsgDesc Nvarchar(Max)
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO [Tbl_Log]([LogDescription])VALUES (@SmsMsgDesc)
declare @LogID int;
SET @LogID = CAST(SCOPE_IDENTITY() AS INT)
INSERT INTO [Tbl_SMS]
([SmsMsgDesc])
VALUES
**(@SmsMsgDesc+CAST(@LogID AS NVarchar(12)))**
END
這裏的問題有時串聯不串連最後一個字符串我不知道爲什麼字符串連接問題
即使我不喜歡這樣
INSERT INTO [Tbl_SMS]
([SmsMsgDesc])
VALUES
**(@SmsMsgDesc+'Test')**
常量'測試'有時不會出現在字符串的末尾,這使我瘋狂,請幫助!
我使用下面的C#函數調用這個程序: -
public int InsertSMSDB(string Message)
{
try
{
//int LogID;
SqlConnection Conn=new SqlConnection(SmsDBConnection);
SqlCommand Comm = new SqlCommand("InsertSMS", Conn);
Comm.CommandType = System.Data.CommandType.StoredProcedure;
Comm.Parameters.AddWithValue("@SmsMsgDesc", Message);
Conn.Open();
int RowEffected=Comm.ExecuteNonQuery();
Conn.Close();
if (RowEffected > 0)
{
return RowEffected;
}
else
{
return -1;
}
}
catch (SqlException ex)
{
return -1;
}
}
最後的一些信息可以在有2個線程訪問Tbl_SMS一個線程插入和1線程應用程序investegating這種情況下幫助對於選擇
什麼是Tbl_SMS.SmsMsgDesc的列類型/大小? – d89761