I am getting an error that is"Invalid object name 't_Images' "
here is my code:

 SqlConnection s = new SqlConnection(con);
            s.Open();
            byte[] data;

            using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
            {
                video.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
                data = stream.ToArray();
            } 

            SqlCommand s_Com = new SqlCommand("INSERT INTO t_Images (Image_ID,Image)"+" VALUES (1,@data) ; ", s);
            SqlParameter param = new SqlParameter();
            param.ParameterName = "@data";
            param.Value = data;
            s_Com.Parameters.Add(param);

            s_Com.ExecuteNonQuery();

my database table t_Images is consisted of 2 coulomns of type id and image. I am using sql server 2008 R2
any help??

You will need to check that you are accessing the correct database, you are logging in as the right user or that the user you are logging in as has the correct permissions to interact with the database or table. You could also be missing the prefix name when it is required (normally DBO).

Edited 4 Years Ago by hericles

Write like this:

INSERT INTO [DATABASE_NAME].[TABLE_NAME] "then your rest of query"

If you create a connection sting for your database in app.Config, create a method called something like DBConnect() and then call that in you SQL command then you won't need to data your database name in you SQL statement. The issue i'm guessing is with:

(1,@data) ; "

Make sure the datatype of the data you're trying to store is compatable with the datatypes of the columns in your DB

Thank you guys, the problem was a misspelling and it was solved :)

great to hear that. It happens.
Just mark the thread as salved - in case if you didnt know that.
bye

Edited 4 Years Ago by Mitja Bonca

This question has already been answered. Start a new discussion instead.