我已經創建了一個用戶定義的類型(有腳本來創建)的SQL Server VARCHAR(最大)incomplate:如何解決操作數類型衝突:圖像下面給出與
CREATE TABLE [dbo].[EmployeeMasters](
[ID] [int] IDENTITY(1,1) NOT NULL,
[EmployeeID] [varchar](max) NOT NULL,
[EmployeeFName] [varchar](max) NOT NULL,
[EmployeeLName] [varchar](max) NOT NULL,
[Photo] [image] NOT NULL)
對我有相同的數據庫創建了一個使用這種類型的程序:
create PROCEDURE EmpQuli_INSERT @EmployeeID varchar(Max),@EmployeeFName VARCHAR(MAX), @EmployeeLName VARCHAR(MAX),@Photo IMAGE AS BEGIN DECLARE @NEWID VARCHAR(10);
DECLARE @PREFIX VARCHAR(MAX);
SET @PREFIX = UPPER(SUBSTRING('STR',1, 3)) SELECT @NEWID = (@PREFIX + replicate('0', 3 -len(CONVERT(VARCHAR,N.OID + 1))) + CONVERT(VARCHAR,N.OID + 1)) FROM (SELECT CASE WHEN MAX(T.TID) IS null then 0 else MAX(T.TID) end as OID FROM (SELECT SUBSTRING(EmployeeID, 3, 1) as PRE_FIX,SUBSTRING(EmployeeID, 3, LEN(EmployeeID))as TID FROM EmployeeMasters) AS T WHERE T.PRE_FIX = @PREFIX) AS N
insert into EmployeeMasters values(@NEWID,@EmployeeFName, @EmployeeLName, @Photo);
end
我嘗試插入在C#中值我得到操作數類型衝突:圖像incomplate在SQL Server中的varchar(最大) ŧ他的c#代碼是:
EmployeeFName.Value = textBox_emp_Fname.Text;
EmployeeLName.Value = textBox_emp_Lname.Text;
Photo.Value =img_arr1;
AddEmployee.CommandText = "EmpQuli_INSERT @EmployeeFName, @EmployeeLName, @Photo";
我不知道是誰來修復它。請幫助我,因爲我必須提交在六月第一週我最後一年的項目,但現在我奮鬥此異常,請幫助....
什麼是'img_arr1'?什麼是「Photo.Value」?如何分配參數? –
我將圖像轉換爲Byte []使用此代碼:MemoryStream ms1 = new MemoryStream(); pictureBox_emp_photo_browse.Image.Save(ms1,System.Drawing.Imaging.ImageFormat.Jpeg); if(ms1.Length> 25000) MessageBox.Show(「請上傳小於25 kb的圖片」); byte [] img_arr1 =新字節[ms1.Length]; ms1.Read(img_arr1,0,img_arr1.Length); –
請給我們看。 –