Forum » Programiranje » Predlog shranjevanja v tabelo
Predlog shranjevanja v tabelo
programercek ::
Zdravo,
kaj se vam zdi takšen način shranjevanja v tabelo:
string CreditCardNumberEncrypt = Encrypt(CreditCardNumber.Text);
string NameOnCardEncrypt = Encrypt(NameOnCard.Text);
MembershipUser myObject = Membership.GetUser();
string UserID = myObject.ProviderUserKey.ToString();
SqlDataSource2.InsertParameters["UserID"].DefaultValue = UserID;
SqlDataSource2.InsertParameters["PaymentType"].DefaultValue = DropDownList4.Text;
SqlDataSource2.Insert();
//Find Max Private key
SqlConnection conn = new SqlConnection("data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\aspnetdb.mdf;User Instance=true");
SqlDataAdapter a = new SqlDataAdapter
("select MAX(PaymentId) from tbl_payments;", conn);
DataSet s = new DataSet();
a.Fill(s);
foreach (DataRow dr in s.Tables[0].Rows)
{
Label3.Text = (dr[0].ToString());
string PaymentId = (dr[0].ToString());
string year = YYYY.Text;
string yearEnd = year.Substring(year.Length - 2);
var TestRecords = new[] {
new { UserID = UserID,
CARDID = PaymentId,
Attribute = "Credit card number",
Value = CreditCardNumberEncrypt },
new { UserID = UserID,
CARDID = PaymentId,
Attribute = "Name on card",
Value = NameOnCardEncrypt },
new { UserID = UserID,
CARDID = PaymentId,
Attribute = "Expiry Date",
Value = MM.Text +"/" + yearEnd }};
foreach (var item in TestRecords)
{
SqlDataSource1.InsertParameters["UserId"].DefaultValue = item.UserID;
SqlDataSource1.InsertParameters["CARDID"].DefaultValue = item.CARDID;
SqlDataSource1.InsertParameters["AttributeName"].DefaultValue = item.Attribute;
SqlDataSource1.InsertParameters["Value"].DefaultValue = item.Value;
SqlDataSource1.Insert();
Kot je razvidno se ključ v stolpcu PaymentId najprej shrani v tabelo, nato ko je ključ shranjen z queryjem najdem zadnji zapis, ki ga nato shranim v drugo tabelo. Tako lahko povežem z joinom
Kaj pravite?
thanks.
kaj se vam zdi takšen način shranjevanja v tabelo:
string CreditCardNumberEncrypt = Encrypt(CreditCardNumber.Text);
string NameOnCardEncrypt = Encrypt(NameOnCard.Text);
MembershipUser myObject = Membership.GetUser();
string UserID = myObject.ProviderUserKey.ToString();
SqlDataSource2.InsertParameters["UserID"].DefaultValue = UserID;
SqlDataSource2.InsertParameters["PaymentType"].DefaultValue = DropDownList4.Text;
SqlDataSource2.Insert();
//Find Max Private key
SqlConnection conn = new SqlConnection("data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\\aspnetdb.mdf;User Instance=true");
SqlDataAdapter a = new SqlDataAdapter
("select MAX(PaymentId) from tbl_payments;", conn);
DataSet s = new DataSet();
a.Fill(s);
foreach (DataRow dr in s.Tables[0].Rows)
{
Label3.Text = (dr[0].ToString());
string PaymentId = (dr[0].ToString());
string year = YYYY.Text;
string yearEnd = year.Substring(year.Length - 2);
var TestRecords = new[] {
new { UserID = UserID,
CARDID = PaymentId,
Attribute = "Credit card number",
Value = CreditCardNumberEncrypt },
new { UserID = UserID,
CARDID = PaymentId,
Attribute = "Name on card",
Value = NameOnCardEncrypt },
new { UserID = UserID,
CARDID = PaymentId,
Attribute = "Expiry Date",
Value = MM.Text +"/" + yearEnd }};
foreach (var item in TestRecords)
{
SqlDataSource1.InsertParameters["UserId"].DefaultValue = item.UserID;
SqlDataSource1.InsertParameters["CARDID"].DefaultValue = item.CARDID;
SqlDataSource1.InsertParameters["AttributeName"].DefaultValue = item.Attribute;
SqlDataSource1.InsertParameters["Value"].DefaultValue = item.Value;
SqlDataSource1.Insert();
Kot je razvidno se ključ v stolpcu PaymentId najprej shrani v tabelo, nato ko je ključ shranjen z queryjem najdem zadnji zapis, ki ga nato shranim v drugo tabelo. Tako lahko povežem z joinom
Kaj pravite?
thanks.
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | PHP in objektno programiranje (strani: 1 2 )Oddelek: Programiranje | 12182 (10649) | kivi113 |
» | Predlog - tabela - plačilni sistemiOddelek: Programiranje | 987 (796) | programercek |
» | [ASP.NET] problemOddelek: Izdelava spletišč | 2186 (1836) | Microsoft |
» | SQL injectionOddelek: Izdelava spletišč | 1979 (1777) | CCfly |