Jump to content
srjohny

duvida webservice função adicionar

Recommended Posts

srjohny

boas pessoal preciso de ajuda fiz um webservice assim

[WebMethod(Description = "Regista Serviço")]
        public int Insertregist(int nserv,string datein, string dateout, int tempo, int cliente)
        {

            int cont = 0;
                SqlConnection conn = new SqlConnection();

            conn.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Trabalho isi\data\isi.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
            {
            conn.Open();

            string query = @"insert into serviço(nserv,datein,dateout,tempo,cliente) values(@nserv,@datein,@dateout,@tempo,@cliente)";
           
            SqlCommand ins = SqlCommand (query, conn);

                //Instanciar parâmetros
            ins.Parameters.Add("@nserv", SqlDbType.Int).Value = nserv;  
           ins.Parameters.Add ("@datein", SqlDbType.Char).Value= datein;
           ins.Parameters.Add ("@dateout", SqlDbType.Char).Value = dateout;
           ins.Parameters.Add ("@tempo", SqlDbType.Int).Value = tempo;
            ins.Parameters.Add ("@nclient", SqlDbType.Int).Value = cliente;

     

                conn.Close();
        }
            return cont;
        }

mas dá erro. aparece isto:

Error 1 'System.Data.SqlClient.SqlCommand' is a 'type' but is used like a 'variable' C:\Trabalho isi\Isi\Isi\Service1.asmx.cs 79 30 Isi

depois  aconselha a gerar um metodo e gera automaticamente fazendo isto:

        private SqlCommand SqlCommand(string query, SqlConnection conn)
        {
            throw new NotImplementedException();
        }

corrige o erro , mas nao dá para adicionar

agradecia k me ajudassem

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.