Solved

C# search SQL and edit resulting Row

Posted on 2014-02-19
4
298 Views
Last Modified: 2014-04-07
Guys I'm trying to put together a C# program to checks SQL DB cell called "ExpirationDate"
if the date is greater than Today, update that rows NAME and PHONE and ExpirationDate with new entry.


DB has.

ll NAME ll  Phone ll ExpirationDate ll
  bob          2122        1/1/2010
  adam       3122        2/2/2010
  greg         4122        3/3/2014

code
has 3 text boxes, one of name, phone and expiration date and a button

can someone point me in the right direction
0
Comment
Question by:kentrg11
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 14

Expert Comment

by:CtrlAltDl
ID: 39871832
How are you accessing the DB?  LINQ, DataReader, etc...

When you say "update that rows", do you mean update in the database, the text boxes, or both?
0
 
LVL 10

Accepted Solution

by:
Banthor earned 500 total points
ID: 39871900
update Table Set col=newvalue where ExpirationDate > Getdate()
0
 

Author Comment

by:kentrg11
ID: 39873870
hey guys thanks im using LINQ

my code is below. On button click i want it to check "ExpirationDate" cell and if the Date
there is less than TODAY. Replace the row with newly entered information in the Text boxes.
So based on the DB i have below. The text entered in text boxes should replace this row
because the date there is less than Today.

32323      kent            1/1/2010

My Code:
 protected void btnAdd_Click(object sender, EventArgs e)
        {
            DBClassesDataContext db = new DBClassesDataContext();
            tblContacts tc = new tblContacts();
            tc.name = txtName.Text;
            tc.phone = txtPhone.Text;
            tc.ExpirationDate = txtExpirationDate.Text;

            db.tblContacts.InsertOnSubmit(tc);
            db.SubmitChanges();


            Response.Redirect("Default.aspx");
        }

Open in new window


DB looks like this:

Number l  Name  l   ExpirationDate
1322232	Jason	       4/4/2014
32323	kent      	       1/1/2010
323233	bog	               3/2/2014
8018932	stephanie       1/2/2012
NULL	NULL	NULL

Open in new window


Aspx:

Name: txtName.Text
Phone: txtPhone.Text
ExpirationDate:  txtExpirationDate.Text
Button: btnAdd
0
 

Author Comment

by:kentrg11
ID: 39894830
CtrlAltDl im saying update the Database itself.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question