Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8640717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:20:51+00:00 2026-06-12T11:20:51+00:00

I have created a stored procedure of insert command for employee details in SQL

  • 0

I have created a stored procedure of insert command for employee details in SQL Server 2005 in which one of the parameters is an image for which I have used varbinary as the datatype in the table..

But when I am adding that parameter in the stored procedure I am getting the following error-

Implicit conversion from data type varchar to varbinary is not
allowed. Use the CONVERT function to run this query.

Stored procedure:

( 
    @Employee_ID nvarchar(10)='', 
    @Password nvarchar(10)='', 
    @Security_Question nvarchar(50)='', 
    @Answer nvarchar(50)='', 
    @First_Name nvarchar(20)='',
    @Middle_Name nvarchar(20)='', 
    @Last_Name nvarchar(20)='', 
    @Employee_Type nvarchar(15)='', 
    @Department nvarchar(15)='', 
    @Photo varbinary(50)='' 
)

insert into Registration
(
      Employee_ID,
      Password,      
      Security_Question,
      Answer,
      First_Name,
      Middle_Name,
      Last_Name,
      Employee_Type,
      Department,     
      Photo     
)
values
(
      @Employee_ID,
      @Password,     
      @Security_Question,
      @Answer,
      @First_Name,
      @Middle_Name,
      @Last_Name,
      @Employee_Type,
      @Department,      
      @Photo   
     )

Table structure:

Column Name        Data Type                 Allow Nulls
Employee_ID    nvarchar(10)             Unchecked
Password       nvarchar(10)              Checked
Security_Question   nvarchar(50)         Checked
Answer             nvarchar(50)              Checked
First_Name     nvarchar(20)              Checked
Middle_Name    nvarchar(20)              Checked
Last_Name      nvarchar(20)              Checked
Employee_Type      nvarchar(15)              Checked
Department     nvarchar(15)              Checked
Photo              varbinary(50)         Checked

Code in vb.net for calling stored procedure->

Public Function Submit(ByVal obj As UserData, ByVal opt As String) As Boolean

    Using cnn As New SqlConnection(conn)
        Using cmd As New SqlCommand
            cmd.Connection = cnn
            If opt = "Submit" Then
                cmd.CommandText = "sp_emp_Registration"
            End If

            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.Add(New SqlParameter("@Employee_ID", obj.EmpID))
            cmd.Parameters.Add(New SqlParameter("@Password", obj.Pwd))
            cmd.Parameters.Add(New SqlParameter("@Security_Question", obj.SecQues))
            cmd.Parameters.Add(New SqlParameter("@Answer", obj.Ans))
            cmd.Parameters.Add(New SqlParameter("@First_Name", obj.Firstname))
            cmd.Parameters.Add(New SqlParameter("@Middle_Name", obj.Middlename))
            cmd.Parameters.Add(New SqlParameter("@Last_Name", obj.Lastname))
            cmd.Parameters.Add(New SqlParameter("@Employee_Type", obj.EmpType))
            cmd.Parameters.Add(New SqlParameter("@Department", obj.dept))                
            cmd.Parameters.Add(New SqlParameter("@Photo", obj.photo))

            cnn.Open()
            Try
                If (cmd.ExecuteNonQuery() > 0) Then
                    cnn.Close()
                    Return True
                Else
                    Return False
                End If
            Catch ex As Exception
                Return False
            End Try
        End Using
    End Using
End Function

I am not getting what to do..can anyone give me some suggestion or solution?
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:20:53+00:00Added an answer on June 12, 2026 at 11:20 am

    You assign a string to a varbinary as default value. This operation don’t perform a implicit cast. To avoid error:

    Change line:

    @Photo varbinary(50)='' 
    

    by:

    @Photo varbinary(50)
    

    If you don’t have Photo value for some rows you should alter table column to allow nulls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Sql Server 2005, I have a stored procedure, in which i have wrote
I created a stored procedure in SQL Server 2012 and I have used scope_identity
Working in SQL Server 2005, I have a stored procedure that inserts a record
I have just created a report in Report Manager using a Stored Procedure which
I have a dynamic SQL statement I've created in a stored procedure. I need
i have this procedure for inserting rows in tables(sql server 2005) CREATE PROCEDURE ans_insert
Afternoon All, I have a stored procedure in an SQL 2005 database named GasNominationsRawData_Insert.
I have stored procedure like this that executed after insert command for any table
I have a stored Procedure (Generate_Insert)which will output an Insert statement as output given
Have created a stored procedure which is utilised for monitoring purposes of a website.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.