hello friends
how to upload xml file and insert in sqlserver 2000 database. regards sanjay
hello friends
how to upload xml file and insert in sqlserver 2000 database. regards sanjay
Well, there are several things here...
uploading a file can be done by dropping a file control on the form and reading from the Files
collection in the page; like so. Then at the server you need to read from the HttpPostedFile
's InputStream
.
If the file is expected to be short, this could be just:
string xml;
using (StreamReader reader = new StreamReader(file.InputStream)) {
xml = reader.ReadToEnd();
}
(and push that string into something like an varchar(max)
/nvarchar(max)
/xml
column via regular methods)
If the file is expected to be long, then you would have to use streaming mechanisms; the most efficient being to treat it as a BLOB (varbinary(max)
) using chunks; here's a slightly older example for image
- with varbinary(max)
the UPDATE
/INSERT
is slightly easier.
Of course, with SQL2008 the file-stream type might be useful too.