My query on button click is this
Dim ms As New MemoryStream()
PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
Dim data As Byte() = ms.GetBuffer()
sql = "insert into emp_det values(?,?,?,?,?,?,?,?,?,?)"
cmd = New SqlCeCommand(sql, con)
cmd.Parameters.Add("@eid", SqlDbType.Float).Value = 10001
cmd.Parameters.Add("@emp_id", SqlDbType.NVarChar).Value = "A123"
cmd.Parameters.Add("@ename", SqlDbType.NVarChar).Value = "Kashif Alvi"
cmd.Parameters.Add("@eadd", SqlDbType.NVarChar).Value = "A 502 Trivedi Plaza Hydri Chowk Naya Nagar Mira Road East"
cmd.Parameters.Add("@mobile_no", SqlDbType.Float).Value = 9773582894
cmd.Parameters.Add("@email_id", SqlDbType.NVarChar).Value = "kashif.alvi39@hotmail.com"
cmd.Parameters.Add("@bg", SqlDbType.NVarChar).Value = "A +ve"
cmd.Parameters.Add("@photo", SqlDbType.Image).Value = data
cmd.Parameters.Add("@dob", SqlDbType.DateTime).Value = DateTimePicker1.Value
cmd.Parameters.Add("@doj", SqlDbType.DateTime).Value = Date.Now
retval = cmd.ExecuteNonQuery
MsgBox(retval)
End Sub
And i am getting an error
The data was truncated while converting from one data type to another. [ Name of function(if known) = ]
Detailed error below
System.Data.SqlServerCe.SqlCeException was unhandled
HResult=-2147467259
Message="The data was truncated while converting from one data type to another. [ Name of function(if known) = ]"
NativeError=25920
Source="SQL Server Compact ADO.NET Data Provider"
StackTrace:
at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr) at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor) at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options) at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery() at Payroll.Form1.Button2_Click(Object sender, EventArgs e) in D:\Kashif\GIV\Payroll\Payroll\Form1.vb:line 64 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(ApplicationContext context) at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) at Payroll.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
InnerException:
What should i do now