# SQL Server Scalar Values

**URL:** https://forum.kirupa.com/t/sql-server-scalar-values/258319
**Category:** programming
**Created:** [April 23, 2008, 1:59am UTC](https://forum.kirupa.com/t/sql-server-scalar-values/258319 "2008-04-23T01:59:20Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Rai\_87](https://avatars.discourse-cdn.com/v4/letter/r/e0b2c6/32.png) [@Rai\_87](https://forum.kirupa.com/u/Rai_87)
#### Post date: [April 23, 2008, 1:59am UTC](https://forum.kirupa.com/t/sql-server-scalar-values/258319/1 "2008-04-23T01:59:20Z")

</div>

i encounter a problem when i debug the website and the error state that must declare the scalar variable “@UserId” and this my code  
[SIZE=2]  
connect.Open();  
cmd.Parameters.AddWithValue([/SIZE][SIZE=2][COLOR=#800000]"@UserId"[/COLOR][/SIZE][SIZE=2], userid);  
[/SIZE]MemoryStream stream = new Memorystream();  
SqlCommand command = new SqlCommand(“SELECT CompanyLogo” from CompleteUserDetails where userid = @UserId);  
byte[] storedImage = (byte[])command.ExecuteScalar();  
[SIZE=2]stream.Write(storedImage, 0, storedImage.Length);  
[/SIZE][SIZE=2][COLOR=#008080]Bitmap[/COLOR][/SIZE][SIZE=2] bitmap = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#008080]Bitmap[/COLOR][/SIZE]SIZE=2;  
Response.ContentType = [/SIZE][SIZE=2][COLOR=#800000]“Image/jpeg”[/COLOR][/SIZE][SIZE=2];  
bitmap.Save(Response.OutputStream, System.Drawing.Imaging.[/SIZE][SIZE=2][COLOR=#008080]ImageFormat[/COLOR][/SIZE][SIZE=2].Jpeg);  
cmd.Parameters.AddWithValue([/SIZE][SIZE=2][COLOR=#800000]"@CompanyLogo"[/COLOR][/SIZE][SIZE=2], image);  
cmd.ExecuteNonQuery();  
connect.Close();

Pls reply me if u know how to solve the problem, i will appriecate ur help…=D  
[/SIZE]
