C# .NET - Which query should i use... - Asked By George on 06-Sep-10 02:08 AM

i have two text boxes, a button and two columns in my access database..... i want whenever i click my button the data in the text boxes should update data in top1 row of the database....
plz suggest which query should i use...
harsh shah replied to George on 06-Sep-10 02:47 AM

below i have given a sp check it. it is a sqlserver sp.

so if need then make similar to Access S.P

CREATE PROCEDURE dbo.[update_first_row]

@filed1         VARCHAR(20),

@field2         VARCHAR(20)


DECLARE @id     int

SELECT @id =   'your TABLE UNIQUE id Field' FROM Table_Name ORDER BY 'your TABLE UNIQUE id Field' desc

WHERE your TABLE UNIQUE id Field=@id


let me know


Harsh Shah
Anand Malli replied to George on 06-Sep-10 02:55 AM
Hi George,

Its simple see the below query,here i am writting query later on you can make SP out of it

UPDATE <table name>
SET <col1>='textbox1 value',<col2>='textbox2 value'
WHERE <col1>=(select top 1 <col1> from <table name>)

just try this and let me know
Priyanka replied to Anand Malli on 06-Sep-10 03:24 AM
 hey dude i tried like this but it is giving error in code ...
the error is Data type mismatch in criteria expression.....
plz make me correct i want to update top1 row...
Priyanka replied to Priyanka on 06-Sep-10 03:46 AM
 no need to reply , i have done this query successfully....
Anand Malli replied to Priyanka on 06-Sep-10 04:29 AM
thats gud...what were the changes that you made?? must have converted to verchar or something with convert...isnt it

if end is well everything is well..gr8 if its solved

thxs :)