I have uploaded an Image into database through C# application. Here is my code. FileStream fs1 = new FileStream(toolStripLableClientSelectedImage.Text, System.IO.FileMode.Open, System.IO.FileAccess.Read); byte[] image = new byte[fs1.Length]; fs1.Read(image, 0, Convert.ToInt32(fs1.Length)); fs1.Close(); SqlCommand cmd = con.CreateCommand(); cmd.CommandText = "INSERT INTO tblClientDetails ([clFname], [clName], [clAddress], [clCity], [clState], [clPhone1], [clPhone2], [clEmail1], [clEmail2], [clProfession], [clPhoto]) VALUES ('" + txtClFirstName.Text + "', '" + txtClLastName.Text + "', '" + txtClAddress.Text + "', '" + cmbClCity.Text + "','" + cmbClState.Text + "' ,'" + txtClPhone1.Text + "' ,'" + txtClPhone2.Text + "' ,'" + txtClMail1.Text + "' ,'" + txtClMail2.Text + "' ,'" + cmbClProfession.Text + "', …

Member Avatar
Member Avatar
+0 forum 6

Hi, I have been working on a application that used sqlserver 2008 R2. we had used filestream that was there in 2008 r2. there was a decision to move from 2008 R2 to 2012 express. Now i understand that file table is a new addition to 2012 and will do the same thing that i want, but out of curiosity i just executed the script to create the table, that has filestream and to my surprise it worked fine. but I soon discovered that for each insert the file is not put into folders as in the 2008 R2. So …

Member Avatar
Member Avatar
+0 forum 2

Hi, I have a filestream enabled DB and a table to store the files. Until now i used to get the path of the file that has to be saved to DB. But due to some changes this was changed and now i get a byte array. my question here is 1. Can this be done? (if yes, then how? Note: the present implementation is a stored procedure that will get the path) 2. Does this implementation have any advantages - performance wise?

Member Avatar
Member Avatar
+0 forum 2

Hello hi. I am seeing flames with using FILESTREAM in SQL Server 2008! I have a table (Products), in which I wanna store a link to an image stored on disk, under the ProdPicture column. This is what the script looks like: CREATE TABLE PRODUCTS ( ProdID INT PRIMARY KEY, ProdName VARCHAR(40), ProdDescription VARCHAR(50), ProdCategory VARCHAR(20), StockOnHand INT, ProdPrice MONEY, ProdPicture VARBINARY(MAX) FILESTREAM ) I have looked up using FILESTREAM online, and came across a number of resources. I followed all the available instructions, even running the script for enabling filestream from within SQL Server, which looks like this: EXEC …

Member Avatar
Member Avatar
+0 forum 1

Hey guys, i'm Working On A Project That Gets All Employees And Their Data From the User Then Saves Them in A Txt File ( Fstream ) Anyway, i figured out how to Do That But What im at stuck at now is how to search through the txt file , i figured that i got to get all the data from the txt file into the console when i start the program so i did all of that and divided all the data between < > For example : < ID > <Name > <Rank>... etc so When he …

Member Avatar
Member Avatar
+0 forum 4

Hi, I am getting an System.OutofmemoryException when using Filestream to load zip file. the file is 521MB. My code is: //Insert using Filestream, file into SQL Server Table private void btnInsert_Click(object sender, EventArgs e) { OpenFileDialog openFileDlg = new OpenFileDialog(); openFileDlg.InitialDirectory = Directory.GetCurrentDirectory(); if (openFileDlg.ShowDialog() == DialogResult.OK) { FileInfo fi = new FileInfo(openFileDlg.FileName); FileStream fs = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read); BinaryReader rdr = new BinaryReader(fs); byte[] fileData = rdr.ReadBytes((int)fs.Length); rdr.Close(); fs.Close(); My program dies on this line: byte[] fileData = rdr.ReadBytes((int)fs.Length); i have also attached the detail for the System.OutofMemoryException. I am runing this on a Windows 7, 64bit machine. …

Member Avatar
Member Avatar
+0 forum 8

I wrote this code for a homework problem. The instructions say that there is a list of phone numbers that were reversed (ex. 6463124137, needs to be 7314213646) and the program needs to reverse them back. My professor also included this hint: [I]"Hint: One way to reverse the number would be to accept all the input as strings, create a temporary string of length 10, and then manually change each character of the string (e.g. temp.at(2)=number.at(8); etc.)"[/I] I tried doing that but the program isn't working. It is not outputting, and there are a few errors. If anyone could explain …

Member Avatar
Member Avatar
+0 forum 11

i have to count three districts 1, 2, 3 whom said no and whom said yes, which i had saved it in notepad the three districts. i have to use the while loop. i was trying ifstream iFile; inFile.open("vote.dat") while(district1 == yes) { cout <<"the district 1 said yes: "; district1++; } while(district1 == no) { cout <<" The district 1 said no:"; distric1++; } while(distric2 == yes) { cout <<"the distric 2 said yes"; distric2++; } i try this way but it does not work

Member Avatar
Member Avatar
+0 forum 1

what is wrong with the ifstream and ofstream? I had try again and again and the info shown run to infinity. :( I tried a lot of times ady, will be glad if anyone can help, thank you :) Sorry if its looks messy, still learning all the way. [CODE] int choice, bound, number, speed, distance, depart, reach, hour, passport, passport1, source1, destination1, dd, dd1, mm, mm1, yy, yy1, ticketprice; string name, name1, type, source, destination, menu, customer, contact, comment, inbound[9], outbound[9]; ifstream InBoundData, OutBoundData; ofstream cinfo; if(bound==1||bound==3) { InBoundData.open("InBoundData.txt"); if (InBoundData.fail()) { cerr<<"ERROR :Cannot open"<<InBoundData<<"for input."<<endl; exit(-1); } cout<<"Type …

Member Avatar
Member Avatar
+0 forum 1

Okay, we had an assignment in computer class that I have been working on for awhile but what I've got so far isn't working. It seems that it may be a compiler issue, but since I can't get to a linux compiler (what the program will be evaluated on), and since I suspect I have some other errors, I figured I would ask it here. I am not asking for you to rewrite the program, but I would like help as soon as possible, as it is due shortly. Here's the problem: 1. Define a class called NumberSet that will …

Member Avatar
Member Avatar
+0 forum 2

Consider those two function. When I load file, everything is fine, but then, when I want to save changes, the file is still being locked. Where is the catch? [CODE=C#] public static string Load(string loadPath = null) { string output; string file = loadPath == null ? _defaultFile : (_defaultFile = loadPath); try { using (var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.None)) { if (!fileStream.CanRead) { Console.Out.Write("File is locked. Waiting for release "); while (!fileStream.CanRead) { Console.Out.Write("."); System.Threading.Thread.Sleep(2000); } } using(var textReader = new StreamReader(fileStream)) { var inputFileDescription = new CsvFileDescription { SeparatorChar = ',', FirstLineHasColumnNames = true }; …

Member Avatar
Member Avatar
+0 forum 1

I am trying to use StreamWriter to debug a stock trading application, and my code creates the file but doesnt write anything to it. I know the method is being executed because other stuff is happening but the file remains empty. I think I am missing something when I create the StreamWriter: public class SterlingDebug : ResponseTemplate { StreamWriter writer = new StreamWriter(@"C:\Documents and Settings\ecoarsey\SterlingIssue10222010.txt"); int i = 0; public override void GotTick(Tick tick) { //StreamWriter writer = new StreamWriter(fs); //print 10 ticks i++; if (i < 11) { D(tick.ToString()); writer.WriteLine("Tick #: {0}",i); } } }

Member Avatar
Member Avatar
+0 forum 3

Hello everyone. I am trying to copy data from a file stream into a char*. I know there are ways to do it with std::string and getline, but I have an assignment where I have to have a class that will take a char* into one of its constructors (which will represent the data in the file), hence forcing me to not use strings. And so, my question really is how do I get file stream data and put it into a char*? I've attempted to do this with the code below, but the program keeps crashing. What is the …

Member Avatar
Member Avatar
+0 forum 5

[code] #include <iostream> using namespace std; using std::cerr; using std::cout; using std::endl; #include <sstream> #include <string> #include <fstream> using std::ifstream; #include <cstdlib> // for exit function // This program reads values from the file '1.txt' // and echoes them to the display until a negative value // is read. int main() { ifstream indata; char num; int sara=0,ri=0,sat=0,ha=0; int some_int=1; ostringstream buffer; buffer << some_int; string s1 =buffer.str(); char s[]=".txt"; strcat(s1,s); //giving error while copmiling indata.open(s1); // opens the file if(!indata) { // file couldn't be opened cerr << "Error: file could not be opened" << endl; exit(1); } indata …

Member Avatar
Member Avatar
+0 forum 7

Hey guys, ive been working on this code for the past couple of hours and I am trying to do the following problem. Write a program that reads the le generated by randGen.cpp (in Problem 1) and stores the numbers in an array of type int. You can assume that there are fewer than 100 entries and your program should determine the actual number of integers in the le (DO NOT USE THE VALUE OF X FROM PROBLEM 1). The output should be a well-formatted two-column list. The rst column is a list of distinct array elements; the second column …

Member Avatar
Member Avatar
+0 forum 1

I have been working on this program for about two weeks. I missed the day that the professor covered the material necessary to code this program due to surgery. I am now behind about 5 programs that are due at the end of the week and I'm trying to teach myself what I've missed. I have asked classmates for help and what they have told me has not been working. If anyone has the free time, I would absolutely love it if you could debug this program for me. I know this community is NOT for giving homework answers. I …

Member Avatar
Member Avatar
+1 forum 6

This seems simple, but it's not working. There IS a text file in the same directory, but it's not being opened (and with the ios::in | ios::out, it should open even if it doesn't exist). I also ran into trouble trying to use infile.fail, which is why I used !infile. Thanks for any help! Rich [CODE] #include <iostream> #include <fstream> #include <string> using namespace std; int main () { // inputting a char from a file to a var and the console char ch; // The test file has one character, 'A'. fstream infile; infile.open("charsfile.txt", ios::in | ios::out); if (!infile) …

Member Avatar
Member Avatar
+0 forum 11

hey im now starting prog in c++ n im being honest- im REALLY flustered i have to create a program to get information from a user, put the info to a file, create another program to read from that file, calculate total scores of x amount of students n grade and output to the screen. i have the parts about getting the info from the user and putting it into a file down...kinda ( there is no space between the variables, and its the loop is not working). i do not know how to ready diff types of data on …

Member Avatar
Member Avatar
+0 forum 2

hi hi, i have a .hex file and i have to read it and convert and sasve it in decimal format. any ideas plzzz

Member Avatar
Member Avatar
+0 forum 8

The End.