2
string s1 = DropDownList1.SelectedItem.Text;
        string s2 = DropDownList2.SelectedItem.Text;
        string sql1 = ("Select Case_Type_Value FROM Case_Type where Case_Type_Text IS'" + s1 + "' ");
        string sql2 = ("Select Case_Status_Value FROM Case_Status where Case_Status_Text IS'" + s2 + "' ");
        int v1 = Int32.Parse(sql1);
        int v2 = Int32.Parse(sql2);

Hi I am getting error "Input string was not in a correct format" on line: int v1 = Int32.Parse(sql1);

3 Answers 3

1

Of course you are getting an error! See you are not fetching result from database. Instead you are assigning your query to sql1 and trying to convert it into integer. See below in your code you are actually assigning whole select query to the string sql1.You can try this one :

        string sql1 = ("Select Case_Type_Value FROM Case_Type where Case_Type_Text IS'" + s1 + "' ");
        string sql2 = ("Select Case_Status_Value FROM Case_Status where Case_Status_Text IS'" + s2 + "' ");
sqlconnection con = new SqlConnection("Blah Blah")
    Sqlcommand cmd = new sqlcommand(sql1,con);
con.open();
     int v1 = Convert.toint32(cmd.ExecuteScalar());
con.close();
con.Dispose();
Sign up to request clarification or add additional context in comments.

Comments

0

Which type you receive when you

string sql1 = ("Select Case_Type_Value FROM Case_Type where Case_Type_Text IS'" + s1 + "' ");
    string sql2 = ("Select Case_Status_Value FROM Case_Status where Case_Status_Text IS'" + s2 + "' ");

?

1 Comment

@ Luffy Case _Type_Value is numeric. Case_Status_Value is also numeric.
0

you can do one thing just take column called Group like you have taken in the Usertype. Take a session variable and capture username in it.Then get the group to which the username belongs. Based on the role redirect the user to his corresponding page.

    Session["unmae"]=txtuname.text;
string username=Session["unmae"].Text;
string group=obj.getgroup(username);
if(group=="Admin")
{
Response.Redirect("1.aspx");
}
else if(group=="User")

{
Response.Redirect("2.aspx");
}
else
{
Response.Redirect("error.aspx");
}

Hope this helps. Happy coding

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.