Click here to Skip to main content
15,921,279 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
code in bll

C#
public DataSet Find(String str)
       {
           if (str == "")
               throw new Exception("Please provide ID to search");

           DataSet ds = null;
           Dal objdal = new Dal();
           ds = objdal.FindRecord(RollNumber);

           return ds;
       }


code in dal

C#
public DataSet FindRecord(int RollNumber)
        {
            DataSet ds = null;
            try
            {
                string command = "Select * from tblstudent where RollNumber=@RollNumber";
                using (SqlConnection con = new SqlConnection(cs))
                {
                    con.Open();
                    SqlDataAdapter da = new SqlDataAdapter("command", con);
                    
                    ds = new DataSet();
                    da.Fill(ds, "tblstudent");
                    con.Close();
                    
                }
            }
            catch (Exception e)
            {
                string st = e.Message;
                
            }
            return ds;
       }

i have added the references as well why it's giving this error? Please let me know thanks in advance
Posted
Updated 1-Nov-14 3:13am
v2

it seems you need to search based on input str, but your method expect integer value and that RollNumber is not defined. try below ( assume you have numbers as input str)

C#
int RollNumber = Convert.ToInt32(str);
ds = objdal.FindRecord(RollNumber);
 
Share this answer
 
Comments
raxhemanth 1-Nov-14 9:25am    
You are right i have mistaken thankyou DamithSL
Maciej Los 1-Nov-14 12:27pm    
+5
DamithSL 1-Nov-14 12:29pm    
Thank you Maciej Los
Praveen_P 2-Nov-14 23:48pm    
gud solution , +5 !
DamithSL 2-Nov-14 23:53pm    
Thank you, Praveepk3
C#
Public DataSet FindRecord(int RollNumber)
{
try{
string command="select * from tblstudent Where rollnumber=@ROLLNUMBER";
using(sqlcommand cmd=new sqlcommand(command,con){
cmd.parameters.add("@ROLLNUMBER", SqlDbType.Int32)=ROLLNUMBER;
sqldataadapter da=new sqldataadapter(cmd);
dataset ds=new dataset();
da.fill(ds);
return ds;
}
}
}
 
Share this answer
 
v2

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



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