Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
please suggest me what i need to do by seeing the below.please kindly help me out am a fresher.
this is my class which contains some properties
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace proinsert
{
    public class insert
    {
        private int mode;

        public int Mode
        {
            get { return mode; }
            set { mode = value; }
        }
        private int stid;

        public int Stid
        {
            get { return stid; }
            set { stid = value; }
        }
        private string stname;

        public string Stname
        {
            get { return stname; }
            set { stname = value; }
        }
        private string staddress;

        public string Staddress
        {
            get { return staddress; }
            set { staddress = value; }
        }
    }
}


this is my dal
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using proinsert;
using System.Data.SqlClient;


namespace studentdal
{
    public class stude
    {
        public SqlConnection con;
        public stude()
        {
            con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=g;Integrated Security=True");
            con.Open();
        }
        public DataView fetch(int stids)
        {

            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "h";
            cmd.Parameters.Add(new SqlParameter("@sid", SqlDbType.Int)).Value = stids;
            SqlDataReader dr = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(dr);
            return dt.DefaultView;

        }
        public int isy(proinsert.insert ayo, out string stadre)
        {
            SqlCommand cm = new SqlCommand();
            cm.Connection = con;
            cm.CommandText = "oi";
            cm.Parameters.Add(new SqlParameter("@mode", SqlDbType.Int)).Value = ayo.Mode;
            cm.Parameters.Add(new SqlParameter("@sid", SqlDbType.Int)).Value = ayo.Stid;
            cm.Parameters.Add(new SqlParameter("@sname", SqlDbType.VarChar)).Value = ayo.Stname;
            cm.Parameters.Add(new SqlParameter("@sad", SqlDbType.VarChar)).Direction=ParameterDirection.Output;
            cm.ExecuteNonQuery();
            stadre = Convert.ToString(cm.Parameters["@sad"].Value);
            return Convert.ToInt32(cm.Parameters["@sad"].Value);
            


        }
    }
}

and am trying to pass value from the asp.net page.kindly please how can pass the value from front end.and my database is
SQL
create database g
use g
create table student(stid int primary key,stname varchar(50),staddress varchar(50))
alter procedure h
(@sid int)
as
begin
if @sid=null
begin
select * from student
end
else
begin
select * from student where stid=@sid
end
end
create procedure oi
(@mode int, @sid int,@sname varchar(80),@sad varchar(30) out)
as
begin transaction
if @mode=1
begin
insert into student values(@sid,@sname,@sad)
end
else
begin
if @mode=2
begin
update student set stname=@sname where stid=@sid
end
end
Posted
Updated 1-Sep-14 8:03am
v2
Comments
Dave Kreskowiak 1-Sep-14 13:51pm    
You haven't said anything about what the problem is other than "it doesn't work". That doesn't help at all.

What error? What's the exception message? What do you expect this code to do? What is it doing?
karthikeyan9966 1-Sep-14 13:58pm    
protected void Button2_Click(object sender, EventArgs e)
{
int a = int.Parse(mode.Text);
int b = int.Parse(id.Text);
stude oki = new stude();
oki.isy(a,b,name.Text,address.Text);
}when am trying to write this code in my asp.net page it is showing Error 4 No overload for method 'isy' takes 4 arguments c:\users\aswin\documents\visual studio 2010\Projects\WebApplication4\WebApplication4\WebForm1.aspx.cs 32 13 WebApplication4

1 solution

Error	4	No overload for method 'isy' takes 4 arguments 

Look at the error message.
Then look at your class:
C#
namespace studentdal
{
    public class stude
    {
        public SqlConnection con;
        public stude()
        {
        ...
        }
        public DataView fetch(int stids)
        {
        ...
        }
        public int isy(proinsert.insert ayo, out string stadre)
        {
        ...
        }
    }
}
You have one method called isy - it takes two parameters, one of them an out parameter.
Now look at how you are calling it:
C#
stude oki = new stude();
oki.isy(a,b,name.Text,address.Text); 
Four parameters, none of them out parameters.

You need to either call the method with just the required two parameters, or write a new method which takes the four you want to give it...
 
Share this answer
 
Comments
Ashi0891 1-Sep-14 14:17pm    
+5. and karthikeyan9966 it was a simple error kid. try checking your code nicely before posting.
OriginalGriff 1-Sep-14 14:27pm    
Sometimes the simple ones are the hardest to see: I frequently read the code I meant to write, rather than what I actually did... :laugh:
Ashi0891 2-Sep-14 6:50am    
haha.. well said.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900