Groups | Blog | Home
all groups > sql server programming > april 2006 >

sql server programming : URGENT HELP! SQL+VB.NET for New Application


Niyazi
4/26/2006 10:01:02 PM
Hi,
I am developing small insurance application using VB.NET and SQL server 2000.
My tables in SQL server are:

tbl_Customer (stores the custmer information)
tbl_CustImage (stores the customer picture and signature)
tbl_InsuranceCompanies (stores the Insurance companies information)
tbl_InsuranceType (stores the insurance type)


tbl_LifeInsurance (stores the LifeInsurance information)
tbl_FireQuakeInsurance (stores the FireQuakeInsuranceinformation)
tbl_CarInsurance (stores the LifeInsurance information)


tbl_BLOBCustomer (store with CustomerID for Document)
tbl_BLOBLIFEInsurance (store with LIFEInsuranceID for Document)
tbl_BLOBFIREQUAKEInsurance (store with FQInsuranceID for Document)
tbl_BLOBCARInsurance (store with CARInsuranceID for Document)

--------------------------------------------------------------------------------

If the Insurance is going to renewed move old data into below table

tbl_OLDLIFEInsurance (store with new ID)
tbl_OLDFIREInsurance (store with new ID)
tbl_OLDCARInsurance (store with new ID)

----------------------------------------------------------------------------------

My question is that when the Insurance going to be renew I need to move old
data in old.... tables and replace the data for the Insurance that going to
be renewed using InsurancePolicyID as ID.

Doing things like in above are correct or not?
And secondly how do I store Word Document or Excel file into SQL server 2000
and later retrive for editinig and restore the documents or excel files?

Thank you very much for your kind understanding for reading my post.

Rgds
Rohit
4/27/2006 3:54:25 AM
Hi
you can format the file into a binary form. Something by this way..

(...)
string sqlInsert = "INSERT INTO o_Documents (fileName, fileContent)
VALUES (@fileName, @fileContent)";
SqlCommand cmdInsert = new SqlCommand(sqlInsert, sqlDBConn);
(...)
//read full file content into memory
FileStream fs = new FileStream(theFile.FullName, FileMode.Open,
FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
byte[] bytes = new byte[fs.Length];
for( long i = 0; i < fs.Length; i++)
{
bytes[i] = r.ReadByte();
}
r.Close();
fs.Close();
(...)
SqlParameter paramFileContent = new SqlParameter("@fileContent",
SqlDbType.VarBinary);
paramFileContent.Direction = ParameterDirection.Input;
paramFileContent.Size = 2147483647;
paramFileContent.Value = bytes;

cmdInsert.Parameters.Add(paramFileName);
cmdInsert.Parameters.Add(paramFileContent);
cmdInsert.ExecuteNonQuery();

Do store the file name and type. This will help you retrived the file.
The field where the file content is to be stored is of type "Image"
Other thing is you can save the file in a folder in the server and
later retirve the file from that path. (That's a risk). I have not
tried doing this for all the file types but only text file. U can try
this

Hope this helps you let me know.


[quoted text, click to view]
Niyazi
4/27/2006 6:16:03 AM
Hi Uri,

I will try the link this weekend. And thank you very much for your kind help.

Hi Rohit,
I was looking your snipset and seems that is what I am looking for. I will
try this weekend and see what I can come up to. I also find word pad like
editor and I will try to mix them and see if I can accopmlish waht I orignaly
had in my mind.

Thank you for your kind help. I will send my post after weekend.

Rgds,
Niyazi













[quoted text, click to view]
Uri Dimant
4/27/2006 8:33:29 AM
Hi
http://www.aspfaq.com/show.asp?id=2149




[quoted text, click to view]

AddThis Social Bookmark Button