A
ahmeddc
Guest
hi
I want to pass and add data to the web service through a desktop program by stored procedure in sql
Stored procedure
ALTER proc [dbo].[insert_user](
@code nvarchar(50), @codeuser nvarchar(50), @pictureuser image,@nameshop nvarchar(50),@country nvarchar(50),@addressuser nvarchar(50),@telephone nvarchar(20),@passworact nvarchar(20),@dateregist date,@active bit)
as
INSERT INTO user_tb(code,codeuser,pictureuser,nameshop,country,addressuser,telephone,passworact,dateregist,active) VALUES
(@code,@codeuser,@pictureuser,@nameshop,@country,@addressuser,@telephone,@passworact,@dateregist,@active)
web service add
[WebMethod]
public int Insertregester(string code, string codeuser, byte pictureuser, string nameshop, string country, string addressuser, string telephone, string passworact, DateTime dateregist, Boolean active)
{
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("@nameshop", SqlDbType.NVarChar).Value = nameshop;
cmd.Parameters.Add("@country", SqlDbType.NVarChar).Value = country;
cmd.Parameters.Add("@addressuser", SqlDbType.NVarChar).Value = addressuser;
cmd.Parameters.Add("@telephone", SqlDbType.NVarChar).Value = telephone;
cmd.Parameters.Add("@passworact", SqlDbType.NVarChar).Value = passworact;
cmd.Parameters.Add("@dateregist", SqlDbType.Date).Value = dateregist.ToShortDateString();
cmd.Parameters.Add("@active", SqlDbType.Bit).Value = active;
if (con.State != ConnectionState.Open)
{
con.Open();
}
retRecord = cmd.ExecuteNonQuery();
}
}
return retRecord
call service code in windows app
Servicea.WebServiceSoapClient _service = new WindowsForm_webservice.Servicea.WebServiceSoapClient();
This is the first time I have used the service.
my try
ms = new MemoryStream();
pictureBox1.Image.Save(ms, ImageFormat.Jpeg);
byte[] photo_aray = new byte[ms.Length];
ms.Position = 0;
ms.Read(photo_aray, 0, photo_aray.Length);
_service.Insertregester(("22"), ("4578"), (photo_aray), (TEXT_NAME.Text), (TEXT_ADDRESS.Text), (TEXT_ADDRESS.Text), (TEXT_TEL.Text), (TEXT_PASSWO.Text),(DATE_PICK.Value.ToShortDateString),(true));
error
Continue reading...
I want to pass and add data to the web service through a desktop program by stored procedure in sql
Stored procedure
ALTER proc [dbo].[insert_user](
@code nvarchar(50), @codeuser nvarchar(50), @pictureuser image,@nameshop nvarchar(50),@country nvarchar(50),@addressuser nvarchar(50),@telephone nvarchar(20),@passworact nvarchar(20),@dateregist date,@active bit)
as
INSERT INTO user_tb(code,codeuser,pictureuser,nameshop,country,addressuser,telephone,passworact,dateregist,active) VALUES
(@code,@codeuser,@pictureuser,@nameshop,@country,@addressuser,@telephone,@passworact,@dateregist,@active)
web service add
[WebMethod]
public int Insertregester(string code, string codeuser, byte pictureuser, string nameshop, string country, string addressuser, string telephone, string passworact, DateTime dateregist, Boolean active)
{
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("@nameshop", SqlDbType.NVarChar).Value = nameshop;
cmd.Parameters.Add("@country", SqlDbType.NVarChar).Value = country;
cmd.Parameters.Add("@addressuser", SqlDbType.NVarChar).Value = addressuser;
cmd.Parameters.Add("@telephone", SqlDbType.NVarChar).Value = telephone;
cmd.Parameters.Add("@passworact", SqlDbType.NVarChar).Value = passworact;
cmd.Parameters.Add("@dateregist", SqlDbType.Date).Value = dateregist.ToShortDateString();
cmd.Parameters.Add("@active", SqlDbType.Bit).Value = active;
if (con.State != ConnectionState.Open)
{
con.Open();
}
retRecord = cmd.ExecuteNonQuery();
}
}
return retRecord
call service code in windows app
Servicea.WebServiceSoapClient _service = new WindowsForm_webservice.Servicea.WebServiceSoapClient();
This is the first time I have used the service.
my try
ms = new MemoryStream();
pictureBox1.Image.Save(ms, ImageFormat.Jpeg);
byte[] photo_aray = new byte[ms.Length];
ms.Position = 0;
ms.Read(photo_aray, 0, photo_aray.Length);
_service.Insertregester(("22"), ("4578"), (photo_aray), (TEXT_NAME.Text), (TEXT_ADDRESS.Text), (TEXT_ADDRESS.Text), (TEXT_TEL.Text), (TEXT_PASSWO.Text),(DATE_PICK.Value.ToShortDateString),(true));
error
Continue reading...