but adding that to paramater how do you place that, because i use parameter alot
cmd.Parameters.AddWithValue("@id", userid);
this is my code
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (!this.Page.User.Identity.IsAuthenticated)
{
FormsAuthentication.RedirectToLoginPage();
}
int userid = this.Page.User.Identity.Name;
GetProfile(userid);
}
}
public void GetProfile(int userid)
{
string str = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
string getADPOST = "GetUSERPRO";
using (SqlConnection con = new SqlConnection(str))
{
con.Open();
using (SqlCommand cmd = new SqlCommand(getADPOST, con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@id", userid);
cmd.Parameters.AddWithValue("@id", userid);
//cmd.Parameters.AddWithValue("@Name", userid);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable ds = new DataTable();
da.Fill(ds);
}
}
}
}
this is the error
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0029: Cannot implicitly convert type 'string' to 'int'
Source Error:
Line 21: }
Line 22:
Line 23: int userid = this.Page.User.Identity.Name;
Line 24: GetProfile(userid);
Line 25: }