Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

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.