C# Programming
09-17-2009, 10:50 AM
Hi All Wizards....
I have this code as an entity and it is working perfectly, but now I try to create the collection for this entity... Can't seem to get it rights... Really need help on this... Thank you all in advance...
Actually, what I try to do is this... I can get only 1 record from the db back at a time, but I want to get nultiple return records from the db....
Here comes the sample codes for entity...
namespace Testing.DataLayer
{
[Serializable]
public class Selected_DocType
{
string userID;
string password;
string doctype;
string fileshortdescription;
public string UserID
{
get { return userID; }
}
public string Password
{
get { return password; }
}
public string DocType
{
get { return doctype; }
}
public string FileShortDescription
{
get { return fileshortdescription; }
}
public Selected_DocType( string userID
, string password
, string doctype
, string fileshortdescription
)
{
this.userID = userID;
this.password = password;
this.doctype = doctype;
this.fileshortdescription = fileshortdescription;
}
public static Selected_DocType GetWebSelected_DocType(string userID, string password)
{
Selected_DocType t = null;
using (SqlConnection conn = Database.CreateConnection())
{
SqlCommand cmd = StoredProcs.GetWebSelected_DocType(conn);
cmd.Parameters["userID"].Value = userID;
cmd.Parameters["password"].Value = password;
cmd.ExecuteNonQuery();
t = new Selected_DocType( userID
, password
, (string)cmd.Parameters["DocType"].Value
, (string)cmd.Parameters["FileShortDescription"].Value
);
return t;
}
}
}
}
I have this code as an entity and it is working perfectly, but now I try to create the collection for this entity... Can't seem to get it rights... Really need help on this... Thank you all in advance...
Actually, what I try to do is this... I can get only 1 record from the db back at a time, but I want to get nultiple return records from the db....
Here comes the sample codes for entity...
namespace Testing.DataLayer
{
[Serializable]
public class Selected_DocType
{
string userID;
string password;
string doctype;
string fileshortdescription;
public string UserID
{
get { return userID; }
}
public string Password
{
get { return password; }
}
public string DocType
{
get { return doctype; }
}
public string FileShortDescription
{
get { return fileshortdescription; }
}
public Selected_DocType( string userID
, string password
, string doctype
, string fileshortdescription
)
{
this.userID = userID;
this.password = password;
this.doctype = doctype;
this.fileshortdescription = fileshortdescription;
}
public static Selected_DocType GetWebSelected_DocType(string userID, string password)
{
Selected_DocType t = null;
using (SqlConnection conn = Database.CreateConnection())
{
SqlCommand cmd = StoredProcs.GetWebSelected_DocType(conn);
cmd.Parameters["userID"].Value = userID;
cmd.Parameters["password"].Value = password;
cmd.ExecuteNonQuery();
t = new Selected_DocType( userID
, password
, (string)cmd.Parameters["DocType"].Value
, (string)cmd.Parameters["FileShortDescription"].Value
);
return t;
}
}
}
}