Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public DataSet ConnectDataBaseReturnDS(string Query)
   {
       ds = new DataSet();
       con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\M\Documents\Visual Studio 2010\Projects\fc 28-3\fc\App_Data\fc.mdf;Integrated Security=True;User Instance=True");
        cmd.CommandText = Query;
       cmd.Connection = con;
      da = new SqlDataAdapter(cmd);
      da.Fill(ds);
       con.Open();
       cmd.ExecuteNonQuery();
       con.Close();
    }


error ocured on keyword dataset,sqldataadpter,and etc... i've define namespace for it.. bt still getting error.. dont knw waht to do..
plz help me out.
is there mistake any i have made????

the error dispaying is
expected class delegate, enum ,interface or struct 
Posted
Updated 8-Apr-13 20:19pm
v3
Comments
Prasad Khandekar 9-Apr-13 2:53am    
There is no SqlCommand object. cmd is uninitialized.

By looking into error you provided it seems that the function is defined outside the class boundary(check your parentheses).

Any function should be defined only inside the boundaries of class delegate, enum ,interface or struct.
 
Share this answer
 
Comments
mahi0607 12-Apr-13 7:06am    
thnks dude for pointing me to my mistake.
Have you added System.Data namespace?

I think you are missing this namepace.

C#
using System.Data;


Add the above namespace and check.
 
Share this answer
 
Comments
mahi0607 9-Apr-13 9:42am    
yes i've put it..
Chinmaya C 9-Apr-13 10:32am    
Could you please post the exception for better understanding...

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