A
ahmeddc
Guest
hi
What is wrong with the way data is entered into stored procedures using the web service.
stored procedures
ALTER proc [dbo].[insert_user](
@code nvarchar(50), @codeuser nvarchar(50), @pictureuser image,@dateregist date,@active bit)
as
INSERT INTO user_tb(code,codeuser,pictureuser,dateregist,active) VALUES
(@code,@codeuser,@pictureuser,@dateregist,@active)
web service insert
[WebMethod]
public int Insertregester(string code, string codeuser, byte[] pictureuser, DateTime dateregist)
{
int retRecord = 0;
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("insert_user", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@code", SqlDbType.NVarChar).Value = code;
cmd.Parameters.Add("@codeuser", SqlDbType.NVarChar).Value = codeuser;
cmd.Parameters.Add("@pictureuser", SqlDbType.Image).Value = pictureuser;
cmd.Parameters.Add("@dateregist", SqlDbType.Date).Value = dateregist.ToShortDateString();
cmd.Parameters.Add("@active", SqlDbType.Bit).Value = true;
if (con.State != ConnectionState.Open)
{
con.Open();
}
retRecord = cmd.ExecuteNonQuery();
}
}
return retRecord;
}
error
ttest page error
The test form is only available for methods with primitive types as parameters.
Continue reading...
What is wrong with the way data is entered into stored procedures using the web service.
stored procedures
ALTER proc [dbo].[insert_user](
@code nvarchar(50), @codeuser nvarchar(50), @pictureuser image,@dateregist date,@active bit)
as
INSERT INTO user_tb(code,codeuser,pictureuser,dateregist,active) VALUES
(@code,@codeuser,@pictureuser,@dateregist,@active)
web service insert
[WebMethod]
public int Insertregester(string code, string codeuser, byte[] pictureuser, DateTime dateregist)
{
int retRecord = 0;
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("insert_user", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@code", SqlDbType.NVarChar).Value = code;
cmd.Parameters.Add("@codeuser", SqlDbType.NVarChar).Value = codeuser;
cmd.Parameters.Add("@pictureuser", SqlDbType.Image).Value = pictureuser;
cmd.Parameters.Add("@dateregist", SqlDbType.Date).Value = dateregist.ToShortDateString();
cmd.Parameters.Add("@active", SqlDbType.Bit).Value = true;
if (con.State != ConnectionState.Open)
{
con.Open();
}
retRecord = cmd.ExecuteNonQuery();
}
}
return retRecord;
}
error
ttest page error
The test form is only available for methods with primitive types as parameters.
Continue reading...