Click here to Skip to main content
15,898,787 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
select distinct
        sec_mrf_details.fnid_int
from    sec_umrf_details
        left join sec_mrf_details on sec_umrf_details.mrfno_nu = sec_mrf_details.mrfno_nu
        left join sec_functions on  sec_functions.fnid_int = sec_mrf_details.fnid_int
        left join sec_roles on sec_roles.roleid_int = sec_mrf_details.roleid_int
        left join sec_modules on sec_modules.modid_int = sec_mrf_details.modid_int
        left join sec_users on  sec_users.userid_vc = sec_umrf_details.userid_vc
where   sec_umrf_details.deleted_int=0
        and sec_umrf_details.userid_vc='i-jadoon' and sec_mrf_details.modid_int = 11
Posted

I suspect you want to set values for 'i-jadoon' and '11' in this code. If so, the best way IMO is to write a stored proc and call it with parameters. You can also use a paramaterised query. What you should NEVER do, is build a string directly by adding constants to the values in textboxes, etc, as these can be hacked.
 
Share this answer
 
Comments
kami124 5-Jul-11 3:04am    
thank you ver much so nice of you
kami124 5-Jul-11 3:31am    
thanks now its work perfectly
Try this one...

SQL
StringBuilder SQL = new StringBuilder("");
SQL.Append("select distinct sec_mrf_details.fnid_int from    sec_umrf_details ");
SQL.Append(" left join sec_mrf_details on sec_umrf_details.mrfno_nu = sec_mrf_details.mrfno_nu ");
SQL.Append("  left join sec_functions on  sec_functions.fnid_int = sec_mrf_details.fnid_int ");
SQL.Append("left join sec_roles on sec_roles.roleid_int = sec_mrf_details.roleid_int
 ");
SQL.Append(" left join sec_modules on sec_modules.modid_int = sec_mrf_details.modid_int ");
SQL.Append("left join sec_users on  sec_users.userid_vc = sec_umrf_details.userid_vc ");
SQL.Append("where   sec_umrf_details.deleted_int=0
        and sec_umrf_details.userid_vc='i-jadoon' and sec_mrf_details.modid_int = 11
 ");
string Query = string.Format(SQL.ToString());
 
Share this answer
 
v3
Comments
kami124 5-Jul-11 3:05am    
Thank you I really appreciate you
Hello,

take a string and assign above to that string
define the sql command and pass that string to sqlcommand.

hoping it will work for you.write comment if more clearification required.
thanks

sanjeev
 
Share this answer
 
Comments
kami124 5-Jul-11 2:58am    
here is the code which i have already done it but still not executing

sql_querry_string = "select distinct sec_mrf_details.fnid_int from sec_umrf_details"
+ "left join sec_mrf_details on sec_umrf_details.mrfno_nu = + sec_mrf_details.mrfno_nu"
+ "left join sec_functions on sec_functions.fnid_int = sec_mrf_details.fnid_int "
+ "left join sec_roles on sec_roles.roleid_int = sec_mrf_details.roleid_int "
+ "left join sec_modules on sec_modules.modid_int = sec_mrf_details.modid_int"
+ "left join sec_users on sec_users.userid_vc = sec_umrf_details.userid_vc"
+ "where sec_umrf_details.deleted_int=0 and sec_umrf_details.userid_vc='i-jadoon' and sec_modules.modid_int=11";



SqlConnection conn = new SqlConnection(sql_string);
str_querry= ("SELECT * FROM sec_modules");
SqlCommand command = new SqlCommand(str_querry);
conn.Open();
SqlDataReader rdr = command.ExecuteReader();

if (rdr.HasRows)
{
while (rdr.Read())
{
string[] functions_access = new string[10];
MessageBox.Show("hello");
MessageBox.Show("you can access the following Functions");
for (int i = 1; i < 10; i++)
{
//functions_access[i].Visible = true;
}

}
}
You should use the stringbuilder class to write long queries.
 
Share this answer
 
Comments
kami124 5-Jul-11 3:04am    
thank you

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