?
Solved

C# search SQL and edit resulting Row

Posted on 2014-02-19
4
Medium Priority
?
300 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 1500 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

777 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