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
Hi,

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)

AS
BEGIN

DECLARE @id     int

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

UPDATE Table_Name SET
field1=@field1,field2=@field2
WHERE your TABLE UNIQUE id Field=@id

end

let me know

Regards,

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
thxs
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 :)