Click here to Skip to main content
15,921,660 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
im storing a file name like "c:/images/Winter9.jpg" in access field which is of memo type
but it gives error
C#
comm.CommandText = "Insert into one_mark" + " (class,subject,chapter_name,question,image,id)values('" + comboBox1.Text + "','" + comboBox2.Text + "','" + comboBox3.Text + "','" + textBox1.Text + "','" + file[0] + "','"+count+"')";
                   comm.Connection = conn;
                   conn.Open();
                   comm.ExecuteNonQuery();
                   conn.Close();

here file[0] is string and it is not working plz help guys!!!!!!!!!!!
Posted
Comments
walterhevedeich 5-Aug-11 13:16pm    
What is the error?

One, you should not be using string concatenation with unvalidated user input. EVER!! Use a parameterized query at the very least.

Perhaps I misunderstood the question, but, if you are assuming that given a filename SQL Server will automatically insert the contents of the file to the database then you are mistaken.

See here[^] for how to add files to SQL Server
 
Share this answer
 
Dear Member,

The problem is with your file[0]'s value. Check for verbatim. File Path should be like "C:\...", but in program it gets values like "C:\\...". So, check that first.

Worried !!!! How to do so? Go for Tracing with F11. Hope this will resolve your issue.

If the solution does not work, please comment on this solution.
 
Share this answer
 
Comments
preet88 12-Aug-11 22:16pm    
when i'm storing the same path in different program it is working well
but it is not working here

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