API for maintain the uploaded file versions in .net [closed] - asp.net

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I am using Microsoft Visual Studio and SQL Server for development.
The problem is initially i upload a file after some time if i upload the another file instead of existing one, then i want to maintain the previous file and also the version are created automatically each time while upload a new file.
Is there any opensource .net API is available to maintain the files with version?
Because i want to show the old files to user when they select roll back option.
Any suggestions please give me how to figure out this...

If you have a database lying around, this can be done with two tables (setting aside the discussion about where to keep actual binary content):
File
----
ID int
Name string(200)
MimeType string(200)
LastRevisionID references Revision.ID, nullable
Revision
----
FileID references File.ID
Content varbinary(max)
When a file is initially uploaded:
begin tran
insert into File ... values ...
insert into Revision .... values ....
update File set LastRevisionID = #lastInsertedRevisionID where ID = #id
commit tran
When a file is updated, first select * from File where Name = #name, remember the LastRevisionID as #lastRevisionID and then:
begin tran
insert into Revision .... values ....
update File set LastRevisionID = #lastInsertedRevisionID
where ID = #id and LastRevisionID = #lastRevisionID
commit tran

Related

When table is select query do it change [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 days ago.
Improve this question
I want to change charset to select calderma table
when table is select query in oracle I would like to make the following changes
ALTER SESSION SET NLS_NUMERIC_CHARACTERS= ',.';
create or replace TRIGGER alter_session AFTER LOGON ON DATABASE
Begin
if ( osuser='solentra') then
execute immediate
'alter session set nls_date_fomat = ''dd-mon-yyyy hh24:mi:ss'' ';
End if;
End;
OR
create or replace TRIGGER alter_session AFTER LOGON ON DATABASE
Begin
if ( SELECT from calderma ) then
execute immediate
'alter session set nls_date_fomat = ''dd-mon-yyyy hh24:mi:ss'' ';
End if;
End;
I don't have much to do with pl\sql but I faced a problem like this, I will be glad if you help

Update in multiview using Linq [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to update details using linq to entities. But instead of takin a new aspx page i want to update details in another view. will it work.? and please give the linq to entity update query
Let us assume:
db is the context of your Database Entity.
Table_name is the name of Table you need to update.
row_id is the value you are using to search for the data in the Table.
To update using linq you need to fetch the record first using the below query:
var data = (from r in db.Table_name
where r.id == row_id
select r).FirstOrDefault();
Now to update the values just update them. For example:
data.Name = "Firstname lastname"
data.IsActive = true;
.
.
and so on
After you have updated the values in data you need to Save the changes made by you by this command:
db.SaveChanges();
That's it.

Mail download save in sql server [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
Does anyone know of a script to download email from Gmail and store it to a SQL server? (for backup purposes)
I am looking for a .NET solution (C#).
EML files are plain text.
Simply create a table in your database with one column (and all the others you need, that's for you to decide) of type nvarchar(max) that will store the contents of the email file. For example call this column email_content
Then do something like this:
string email = File.ReadAllText("Path/to/EML/File");
And then do something like:
using (SqlConnection con = new SqlConnection("YourConnectionStringHere"))
{
con.Open();
using(SqlCommand command = new SqlCommand("INSERT INTO your_table (email_content) values (#email_content)",con)
{
command.Parameters.AddWithValue("#email_content",email);
command.ExecuteNonQuery();
}
}
*That's assuming you are using SQL Server but the principle is the same for any other database.

last record from database [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Get the last record from a Microsoft SQL database table using ASP.net (VB) onto a web form.
I'm assuming he's trying to retrieve the last inserted record. As Ariel pointed out, the question is rather ambiguous.
SELECT TOP 1 * FROM Table ORDER BY ID DESC
If you have an identity column called ID, this is easiest. If you don't have an identity PK column for example a GUID you wont be able to do this.
Here is a basic solution:
var order = (from i in db.orders
where i.costumer_id.ToString() == Session["costumer_id"]
orderby i.order_id descending
select i).Take(1).SingleOrDefault();
You need to be more specific with actually putting it onto a web form, but the SQL to get the last record is:
SELECT *
FROM TABLE_NAME
WHERE ID = (SELECT MAX(ID) FROM TABLE_NAME)
Where ID is your ID and TABLE_NAME is your table name.

Where can I get a simple table of time zones for use in SQL server? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I just need to make a SQL table of time zones - at this point, my only need is to populate a drop-down list on an online form. I'm envisioning something simple with columns for ISO code, name, UTC offset, and perhaps a list of representative cities. I thought I would be able to easily find something online to copy-and-paste, but haven't been able to locate anything.
I was directed by this question to the tz database, which is in binary form and seems like overkill for what I need. Alternatively I could piece this together from sites like TimeAndDate.com, but that seems like more work than should be necessary.
Or am I going about this the wrong way - e.g. should I be getting this information from the server's OS?
the list of all timezone are here:
select * from sys.time_zone_info
Enjoy!
Are you on .NET 3.5 ? You can easily get a list of timezones in .NET 3.5 and then store that information (or at least whatever you need of it) in your SQL Server database.
You could iterate over all timezones available and known to .NET 3.5 and store the relevant info to a SQL Server table:
ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
foreach (TimeZoneInfo timeZone in timeZones)
{
// store whatever you need to store to a SQL Server table
}
Marc
I took marc_s answer a step further - here's the code to create a simple timezone table and .net code that generates the inserts for each UTC record:
--TSQL TO CREATE THE TABLE
CREATE TABLE [dbo].[TimeZones] (
[TimeZoneID] INT IDENTITY (1, 1) NOT NULL,
[DisplayName] VARCHAR(100) NOT NULL,
[StandardName] VARCHAR (100) NOT NULL,
[HasDST] BIT NOT NULL,
[UTCOffset] INT NOT NULL
CONSTRAINT [PK_TimeZones] PRIMARY KEY CLUSTERED ([TimeZoneID] ASC)
);
GO
To generate the insert statements, I created a default web .net project using visual studio and in the view I pasted this, ran the project and then copied the rendered code (remember to copy it from view source, not from directly the html page):
System.Collections.ObjectModel.ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
foreach (TimeZoneInfo timeZone in timeZones)
{
Response.Write("INSERT INTO TimeZones (DisplayName, StandardName, HasDST, UTCOffset) VALUES ('" + timeZone.DisplayName.Replace("'", "''") + "', '" + timeZone.StandardName.Replace("'", "''") + "', '" + timeZone.SupportsDaylightSavingTime + "', '" + timeZone.BaseUtcOffset + "')" + Environment.NewLine);
}
Hope this helps
I you want a good list to copy/paste from : http://en.wikipedia.org/wiki/Timezones
Get it from the OS.
In that you've tagged this asp.net have a look at this example of how to enumerate timezones.
I know this question was asked long time ago but for anyone that might still need it, here is where you can find an sql data of timezone list https://timezonedb.com/download

Resources