C# .NET - Which query should i use...
Asked By George
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
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
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
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
no need to reply , i have done this query successfully....
Anand Malli replied to Priyanka
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 :)

Querry How we create index?can anyone give example of cluster and noncluster indexes. . . . Hi, When I first started populating it with some sample data using the following scripts. I assume you have a database you can use for this. If not, you will want to create one for these examples. Create Table DummyTable1 ( EmpId Int, EmpName Varchar(8000) ) When you first create a new table, there is no index created by default. In technical terms, a table for this table with an of indid = 0. The sysindexes table, which exists in every database, tracks table and index information. “Indid” refers to Index ID, and is used to identify indexes. An indid of 0 means that a table does Index and ordinary index), PageType tells you what kind of data is stored in each database, Where: 10 – IAM (Index Allocation MAP) 1 – Datapage 2 – Index page Now, let us execute
a tabpage: a textbox, a datetimepicker and a datagridview and 3 records in the dataset: ID = 1, 2, 3 LastName = 'X', 'Y', 'Z' and StartDate = '2010 / 1 / 1', '2010 / 2 / 2', '2010 / 3 / 3' order by StartDate desc. The data of the most recent one (ID = 3) is shown in the tbx / dtp to be modified and the other records in dataset where the first has a rowfilter making that only one record is withheld (.RowFilter = "ID = 3") and bound to the tbx and dtp, and the other view has a rowfilter making that all except the first one are shown in the grid (.RowFilter = "ID<> 3"). And now: - Modifying the first dataview trough the tbx and / or dtp and saving the dataset works. - Deleting the one record in the first dataview, getting the ID of the first record in the second dataview and adapting the rowfilters to shift the wole up works (thisID = dataview2.item(0)("ID") dataview1. . RowFilter = "ID = " & thisID and dataview2.RowFilter = "ID<> " & thisID), except that I can't get the binding with
two queries(Insert and update) in one stored procedure HI. . . I am using C# and sqlserver 2005 i would like to write two queries(Insert and update) in one stored procedure. . i have a registration page in this when i entered a new record(ex: 11th then the new record will be successfully insert at the same time i have to update the email address which i entered in the new record this email address field will be update in the last 10 records simantanesly. . .pls help me. . . If this needs to be done auto-incremented column or auto-generated system date column in your table? If so your Procedure would do some thing like, INSERT INTO <table> . . . and then, UPDATE <table> SET <email column
Upload button, save the rows in the .xls file to an existing table on the database server So, if the existing database table has 10 rows, and the user's .xls file has 10 rows, after the a file. Read this excel file into say a DataSet and on the server side update the DB from this DataSet? How can I save up to the db server? The Insert into ExcelImport Select * FROM OPENROWSET" strSQL & = "('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database = C: \ TestSaving \ " & ServerFileName & ";""" strSQL & = "HDR = YES ', 'SELECT * FROM [Sheet1$]')" Label3.Text = strSQL.ToString() Dim cmd form> _ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ _ here is db-multiple-file-to-diskfolder.asp code <%@LANGUAGE = "VBSCRIPT"%> <% 'Sample file Field-SaveAs.asp 'Store extra upload info to a database ' and file contents to the disk Server.ScriptTimeout = 5000 'Create upload form 'Using Huge-ASP file upload 'Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm FILE = "_upload.asp"- -> <% Server.ScriptTimeout = 1000 Form.SizeLimit = 10240*1024'10MB '{b}Set the upload ID for this form. 'Progress bar window will receive the same ID. if len(Request.QueryString
procdeure to get all the filed names(not the values) in this fomat. (fieldname)field1 = @field(fieldname) (fieldname)field2 = @field(fieldname) and @fieldname1, @fieldname2, . . . . . . Please help me out. Thank you. Keerthi.Cheluvaraj. This way: See the example: CREATE PROCEDURE blockdet6(@pid char(20)) AS select * from blockdet where projid = @pid SELECT table_name = sysobjects.name column_name = syscolumns.name, datatype = systypes.name, length = syscolumns.length FROM sysobjects JOIN syscolumns ON sysobjects.id = syscolumns.id JOIN systypes ON syscolumns.xtype = systypes.xtype WHERE sysobjects.xtype = 'U' ORDER BY sysobjects.name table NAme' Use this: SELECT syscolumns . name AS FieldsInTable FROM sysobjects JOIN syscolumns ON sysobjects . id = syscolumns . id WHERE sysobjects . name = 'spt_values' / / Put your table name here Hello - -- Run this Query using the