Hi, I kind of hit a bump in the road with SQL and C#.
I am sending information through to a stored proc like:
SqlCommand TestCaseManager = new SqlCommand("TestCaseManager", thisConnection);
TestCaseManager.CommandType = CommandType.StoredProcedure;
TestCaseManager.Parameters.Add(new SqlParameter("@TestCaseName", TestCaseName));
if (c.Controls[2].Text.Equals(string.Empty))
{TestCaseManager.Parameters.Add(new SqlParameter("@Steps", DBNull.Value));}
else
{TestCaseManager.Parameters.Add(new SqlParameter("@Steps", c.Controls[2].Text));}
if (UnitTester.GroupBoxCreator.SomeClass.PictureLocation.Count.Equals(0))
{TestCaseManager.Parameters.Add(new SqlParameter("@Img", DBNull.Value));}
else
{byte[] Img = File.ReadAllBytes(UnitTester.GroupBoxCreator.SomeClass.PictureLocation[r].ToString());
TestCaseManager.Parameters.Add(new SqlParameter("@Img", Img));}
thisConnection.Open();
object ObjTestCaseManager = TestCaseManager.ExecuteScalar();
thisConnection.Close();
and my stored proc looks like:
USE [TestCaseManager]
GO
/****** Object: StoredProcedure [dbo].[TestCaseManager] Script Date: 01/03/2014 10:49:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[TestCaseManager]
@TestCaseName nvarchar(MAX), @Steps nvarchar(MAX), @Img image
AS
DECLARE @SqlCommand nvarchar(MAX)
SET @SqlCommand = 'INSERT INTO '+@TestCaseName+' ([Steps], [Img]) VALUES (' +@Steps+', '+@Img+')'
EXEC(@SqlCommand)
The error that I receive for the SQL part is : "The data types nvarchar(max) and image are incompatible in the add operator."
Any help would be appreciated. Thanks