-2

Hi please having a problem with the connection string. Trying to call a stored procedure in C#... HERE'S MY CODE

            SqlConnection conn = new SqlConnection("Hunt_Lisa");
            SqlCommand command = new SqlCommand("blkFinance_noheader", conn);
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@Path", fn));
            command.ExecuteNonQuery();

I appreciated your help in advance...

Jake
  • 93
  • 7
  • possible duplicate of [Format of the initialization string does not conform to specification starting at index 0](http://stackoverflow.com/questions/5219676/format-of-the-initialization-string-does-not-conform-to-specification-starting-a) – PiousVenom Mar 23 '15 at 18:54
  • 2
    Googling that error came up with 3 other SO's with the same exact title. One of them is bound to be an answer for you. – PiousVenom Mar 23 '15 at 18:55
  • take a look here to make sure that you are formatting your connection string properly since you have not show what the actual connection string looks like [C# connection Strings](http://www.connectionstrings.com) also when trying to execute query's wrap your code around 2 of the following `1 using(){} 2 try{}catch{}` – MethodMan Mar 23 '15 at 19:03

1 Answers1

0

Here's my revised version of the script... Just want to share

using (SqlCommand cmd = new SqlCommand())
            {

                cmd.Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Hunt_Lisa"].ConnectionString);
                cmd.CommandText = "blkFinance_noheader";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Path", SqlDbType.Text).Value = fn;
                cmd.Connection.Open();
                cmd.ExecuteNonQuery();
                cmd.Connection.Close();

            }
Jake
  • 93
  • 7