i have error when insrt zip into sql server in c#

asked 2021-04-18T21:02:07.4+00:00
Hoshang Hassan 21 Reputation points

error

An unhandled exception of type 'System.NotSupportedException' occurred in mscorlib.dll

Additional information: The given path's format is not supported.

code

if (tid.Text == "" || tname.Text == "" || tlink.Text == "")
MessageBox.Show("Please insert information");
else
{
string filePath = @"'" + tlink.Text + "'";
byte[] bytes = File.ReadAllBytes(filePath);
SqlConnection conn = new SqlConnection(@"Data Source=.;Initial Catalog=StudentProject;Integrated Security=True");
SqlCommand insert = new SqlCommand("insert into network values(@f1,@f2,@f3,f4,f5,f6,f7,f8,f9");
insert.Parameters.AddWithValue("@f1",tid.Text);
insert.Parameters.AddWithValue("@f2",tname.Text);
insert.Parameters.AddWithValue("@f3",textBox1.Text);
insert.Parameters.AddWithValue("@f4",textBox2.Text);
insert.Parameters.AddWithValue("@f5",textBox3.Text);
insert.Parameters.AddWithValue("@f6",textBox4.Text);
insert.Parameters.AddWithValue("@f7",textBox5.Text);
insert.Parameters.AddWithValue("@f8",textBox6.Text);
insert.Parameters.AddWithValue("@f9", bytes);
conn.Open();
insert.ExecuteNonQuery();
conn.Close();

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,910 questions
{count} votes

Accepted answer
  1. answered 2021-04-19T04:48:38.983+00:00
    Viorel 82,286 Reputation points

    If tlink.Text is a valid file path, then try this:

    string filePath = tlink.Text;
    byte[] bytes = File.ReadAllBytes(filePath);
    

    Show an example of tlink.Text if it still never works.


0 additional answers

Sort by: Most helpful