Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking information in dataset

Status
Not open for further replies.

rac55

Programmer
Jul 1, 2003
62
AU
Hi

I am trying to check the database to see if there is a value year = '2004'...does anyone have any ideas how to do this?

Code is;

If DS.Tables("tblExpiryDate").Rows.Count > 0 Then

rsExpiry.DataSource = DS

rsExpiry.DataBind()

rsExpiry.Visible = True

Dim cmd As New SqlCommand("UPDATE tblExpiryDate SET ExpYear = ('" & txtYear.SelectedItem.Text & "'),ExpDate =('" & thisDate & "')", MyConnection)
cmd.ExecuteNonQuery
MyConnection.Close()
Response.write ("Update table")

Else

rsExpiry.Visible = False
Dim cmd As New SqlCommand("INSERT INTO tblExpiryDate (ExpYear, ExpDate) VALUES ('" & txtYear.SelectedItem.Text & "', '" & thisDate & "')", MyConnection)
cmd.ExecuteNonQuery
MyConnection.Close()
Response.write ("Insert table")
End If

Any help would really be appreciated

Thanks
Rachel
 
You can use
if exists(select mydate from tablename where cast(mydate as varchar) like '2004%')

in Sql server.
Regrs
siva
 
Hi

I have managed to get this working...thanks very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top