Showing posts with label retrieve. Show all posts
Showing posts with label retrieve. Show all posts

Friday, February 24, 2012

checking password

i used this code to retrieve customer_ID from a database given a userid and password
how to retrieve the customer_ID
my code:
public static int CheckPassword(string userid,string pass)
{

SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["connString"]);
String strCheckPassword=@."Select Customer_ID from Customers Where UserID='" +userid+ "' "+"AND Password='"+pass+"'";
//name of the stored proceedure and command type set to StoredProceedure
SqlDataAdapter adp=new SqlDataAdapter(strCheckPassword,conn);
DataSet ds=new DataSet();
conn.Open();
adp.Fill(ds);
result=//this must retrieve customer_id from dataset ds; //help here

conn.Close();
return result;
}solved using Datareder get- method;

Sunday, February 12, 2012

Checkbox with the same name truncates at a space

When I use SQL to populate a checkbox and give the checkboxes all the same name, when I retrieve it a name containing a space is truncated at the space. How can I get the whole name?

<%while NOT rs.EOF%>
<INPUT TYPE=CHECKBOX NAME="code" value=<%=rs("code")%> <%If request.Form("code") = rs("code") then%> CHECKED <%End If%>><%=rs("code")%><br>
<%rs.MoveNext
wend
rs.Close%>

strStatus_code = Request.Form("code")

gives me Active, Inactive, Phase

what I want is gives me Active, Inactive, Phase Out

:confused:This is not a problem with SQL, but with the way you are writing out the values.

Place quotes around the value when you write them out for display, so that when you do a view source from the browser you should see.

"Active"
"Inactive"
"Phase Out"

<%while NOT rs.EOF%>
<INPUT TYPE=CHECKBOX NAME="code" value=" <%=rs("code")%>"
<%If request.Form("code") = rs("code") then%> CHECKED <%End If%>>" <%=rs("code")%>" <br>
<%rs.MoveNext
wend
rs.Close%>|||Worked perfectly!! Thank you.:) :) Suzy