Click here to Skip to main content
15,896,557 members

Comments by suma2212 (Top 30 by date)

suma2212 25-Mar-13 3:48am View    
sorry for the trouble i am using this

SqlDataReader dr = command.ExecuteReader();

while (dr.Read())
{
if (dr["emailId"].ToString() !=txtenrEmail.Text)
{
Label1.Text = "Emailid already exists. Use another EmailId";
}
else
{
Label1.Text = "User details Inserted successfully";
}
}

String strQuery = "";
SqlConnection mySqlConnection = new SqlConnection(str);

strQuery += "update PersonalDetails set EnrolmentNo= ('CD' + ' " + dr["userid"].ToString() + " ') where userid = ' " + Convert.ToInt32(dr["userid"]) + " ' ";
SqlCommand com = new SqlCommand(strQuery, mySqlConnection);
mySqlConnection.Open();
com.ExecuteNonQuery();
mySqlConnection.Close();

con.Close();

please check it once......
suma2212 25-Mar-13 3:16am View    
i want to read 2 values userid and emailid. so i used sql reader.... please check above code...
suma2212 25-Mar-13 3:03am View    
ya i got it.thanx for ur help......

is this code correct?

while (dr.Read())
{
if (dr["emailId"].ToString() !=txtenrEmail.Text)
{
Label1.Text = "User details Inserted successfully";
}
else
{
Label1.Text = "Emailid already exists. Use another EmailId";

}
}

if that emailid is already exists i got this message
Label1.Text = "Emailid already exists. Use another EmailId";
and emailid not exists also i am getting same message..


please help me..
suma2212 25-Mar-13 2:38am View    
Hi i used if(dr.HasRows)
{
}
but i got this error

Object cannot be cast from DBNull to other types.
please help me.......
suma2212 6-Mar-13 8:06am View    
<tr>
<td class="style7" >
User Name</td>
<td >
<asp:TextBox ID="txtUsername" runat="server">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtUsername" ErrorMessage="*" ValidationGroup="submit">
</td>
</tr>
<!-- password -->
<tr>
<td class="style7" >
Password</td>
<td >
<asp:TextBox ID="txtpwd" runat="server" TextMode="Password">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtpwd" ErrorMessage="*" ValidationGroup="submit">
</td>
</tr>
<tr>
<td class="style8" colspan="2">
                  
<asp:ImageButton ID="ImageButton2" runat="server"
ImageUrl="http://localhost:3072/HAI/UserAdmin/Images/btns_24.jpg" onclick="ImageButton2_Click"
ValidationGroup="submit" />
</td>
</tr>
<tr>
<td class="style7" colspan="2" >
<asp:Label ID="Label1" runat="server" Font-Size="Small" ForeColor="#CC0000">
 </td>
</tr>
</table>

</td>
</tr>

</table>



</div></div></div>

<!-- END subscribe popup-->
</form>
</body>
</html>

view code:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["userid"] == null)
{
//this.Button1.OnClientClick = "javascript:('Button1','')";
this.Button1.Attributes.Add("OnClientClick", "javascript:test();");
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Request.QueryString["userid"] != null)
{
SqlConnection con = new SqlConnection(str);
SqlCommand com = new SqlCommand("Hai_insertstorydetailes", con);
con.Open();
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add("@userId", Request.Cookies["userId"].Value.ToString());
if (Request.QueryString["StoryId"] != null)
{

com.Parameters.Add("@Id", Request.QueryString["StoryId"].ToString());
}
com.Parameters.Add("@Headline", txtheadline.Text);
com.Parameters.Add("@WriteStory", txtstory.Text);
com.Parameters.Add("@Destination", txtdestination.Text);
com.Parameters.Add("@Date", txtdate.Text);
com.ExecuteNonQuery();
con.Close();
}
else
{

}

this code working for hyperlink. but when i apply to button its not working...
when i submit review if user logged in it will save in db. other modelpodel popup window will open and when i submit user credentials it will go to that review page.

please help me........