Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I FIND A CODE FOR save file to DB. BUT the "locale" can't be recognize by VS2010

C#
byte[] file;
            using (var stream = new FileStream(varFilePath, FileMode.Open, FileAccess.Read))
            {
                using (var reader = new BinaryReader(stream))
                {
                    file = reader.ReadBytes((int)stream.Length);
                }
            }
            using (var varConnection = Locale.sqlConnectOneTime(Locale.sqlDataConnectionDetails))
            using (var sqlWrite = new SqlCommand("INSERT INTO Raporty (RaportPlik) Values(@File)", varConnection))
            {
                sqlWrite.Parameters.Add("@File", SqlDbType.VarBinary, file.Length).Value = file;
                sqlWrite.ExecuteNonQuery();


Thanks
Posted
Updated 3-Dec-14 12:31pm
v2
Comments
Sergey Alexandrovich Kryukov 3-Dec-14 17:50pm    
You cannot do programming by "finding code". The problem is, however, the file itself. Who knows what's in it? :-)
—SA
Garth J Lancaster 3-Dec-14 18:33pm    
the code snippet on its own is not enough to figure out what

Locale.sqlConnectOneTime(Locale.sqlDataConnectionDetails))

is/means - you need to post more (relevant) details

1 solution

Locale is a Class that contains the method sqlConnectOneTime. If you expect to program by finding source code, you will have to find the source code for Locale.

If you can't find it, you will have to write your own code to instantiate the SQLConnection object. Try looking at the Visual Studio help files for examples.

Here is one example: SQLConnection[^]
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900