请教一下关于留言的存储过程
USE test
存储过程的代码如下:
GO
CREATE PROCEDURE Addword
@gName varchar(50),
@gCity varchar(50),
@gMail varchar(50),
@gQQ varchar(50),
@gURL varchar(50),
@gTitle nvarchar(200),
@gContent ntext
AS
INSERT INTO Gbook(gbName,gbCity,gbMail,gbQQ,gbURL,gbTitle,gbContent)
VALUES(@gName,@gCity,@gMail,@gQQ,@gURL,@gTitle,@gContent)
GO
提交的代码如下:
SqlConnection Conn = new SqlConnection( "Data Source=localhost;Initial Catalog=test;User ID=sa;Password=123 ");
SqlCommand Comm = new SqlCommand( "Addword ", Conn);
Comm.CommandType = CommandType.StoredProcedure;
Comm.Parameters.Add( "@gName ", SqlDbType.VarChar);
Comm.Parameters.Add( "@gCity ", SqlDbType.VarChar);
Comm.Parameters.Add( "@gMail ", SqlDbType.VarChar);
Comm.Parameters.Add( "@gQQ ", SqlDbType.VarChar);
Comm.Parameters.Add( "@gURL ", SqlDbType.VarChar);
Comm.Parameters.Add( "@gTitle ", SqlDbType.nvarchar);
Comm.Parameters.Add( "@gContent ", SqlDbType.ntext);
//给存储过程的参数付值
Comm.Parameters[ "@gName "].Value = gName.Text;
Comm.Parameters[ "@gCity "].Value = gCity.Text;
Comm.Parameters[ "@gMail "].Value = gMail.Text;
Comm.Parameters[ "@gQQ "].Value = gQQ.Text;
Comm.Parameters[ "@gURL "].Value = gURL.Text;
Comm.Parameters[ "@gTitle "].Value = gTitle.Text;