Click here to Skip to main content
15,900,435 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Runtime error '91' Pin
nlarson1124-Sep-08 3:45
nlarson1124-Sep-08 3:45 
GeneralRe: Runtime error '91' Pin
Pedram Behroozi24-Sep-08 5:40
Pedram Behroozi24-Sep-08 5:40 
GeneralRe: Runtime error '91' Pin
nlarson1124-Sep-08 6:09
nlarson1124-Sep-08 6:09 
GeneralRe: Runtime error '91' Pin
Dave Kreskowiak24-Sep-08 9:12
mveDave Kreskowiak24-Sep-08 9:12 
GeneralRe: Runtime error '91' Pin
nlarson1124-Sep-08 10:03
nlarson1124-Sep-08 10:03 
GeneralRe: Runtime error '91' Pin
ChandraRam25-Sep-08 1:06
ChandraRam25-Sep-08 1:06 
AnswerRe: Runtime error '91' (Done!) Pin
Pedram Behroozi25-Sep-08 3:50
Pedram Behroozi25-Sep-08 3:50 
QuestionProblem With Saving Image in Binary format Pin
Saba0223-Sep-08 16:35
Saba0223-Sep-08 16:35 
Hi all,

i'm trying to save an image in database ina binary format,

Image:Is my table name
Pic is my column name

these are my functions:

<WebMethod()> _
Public Function ImageToByte(ByVal filepath As String) As Byte()
Dim fs As FileStream = New FileStream(filepath, FileMode.Open, FileAccess.Read)
Dim BR As BinaryReader = New BinaryReader(fs)
Dim photo As Byte() = BR.ReadBytes(fs.Length)
BR.Close()
fs.Close()
Return photo
End Function

<WebMethod()> _
Public Sub saveimage(ByVal imagebyte As Byte())
Dim cnn As New SqlConnection("myconnectionstring")

Dim cmd As New SqlCommand()
Dim da As New SqlDataAdapter()
Dim cbuilder As New SqlCommandBuilder(da)
Dim ds As New DataSet()
Dim cmdStr As String

cmdStr = "SELECT * FROM Image"
If cnn.State = ConnectionState.Open Then
cnn.Close()
End If

cnn.Open()
cmd.Connection = cnn
cmd.CommandText = cmdStr
da.SelectCommand = cmd
da.Fill(ds, "Image")

Dim nrow As DataRow
nrow = ds.Tables("Image").NewRow()
nrow.Item("Pic") = imagebyte

ds.Tables("Image").Rows.Add(nrow)
da.InsertCommand = cbuilder.GetInsertCommand
da.Update(ds.Tables("Image"))
cnn.Close()
End Sub

and this is my code for using this functions:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ws As New localhost.Service()
Dim a As Byte()
a = ws.ImageToByte(TextBox1.Text)
ws.saveimage(a)

But when i click on Button1 this Error occured:
SQLException was unhandled by user code

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: String or binary data would be truncated.

why this error occured?
please help me,

Thank You

Hoda

AnswerRe: Problem With Saving Image in Binary format Pin
N a v a n e e t h23-Sep-08 17:48
N a v a n e e t h23-Sep-08 17:48 
QuestionAccess combobox binding and relationships Pin
Member 435504923-Sep-08 11:48
Member 435504923-Sep-08 11:48 
QuestionHow to GetMethod that use Dynamic Parameter (TypeParam)? Pin
f3rland23-Sep-08 11:01
f3rland23-Sep-08 11:01 
QuestionError: "Invalid Parameter Used" when i try to display an image [modified] Pin
Member 367504723-Sep-08 3:37
Member 367504723-Sep-08 3:37 
QuestionPLEASE HELP ME Pin
sidwithu23-Sep-08 3:31
sidwithu23-Sep-08 3:31 
AnswerRe: PLEASE HELP ME Pin
Dave Kreskowiak23-Sep-08 7:02
mveDave Kreskowiak23-Sep-08 7:02 
QuestionReport Printining Pin
Gagan.2023-Sep-08 1:13
Gagan.2023-Sep-08 1:13 
QuestionConvert Topographic Map/ Contour Map Pin
Tan Yih Sheng22-Sep-08 23:45
Tan Yih Sheng22-Sep-08 23:45 
Questioncreating ascii file in mc1000 Pin
jayv0122-Sep-08 22:28
jayv0122-Sep-08 22:28 
AnswerRe: creating ascii file in mc1000 Pin
ChandraRam23-Sep-08 0:54
ChandraRam23-Sep-08 0:54 
GeneralRe: creating ascii file in mc1000 Pin
jayv0123-Sep-08 11:25
jayv0123-Sep-08 11:25 
QuestionWebBrowser Drag/Drop Support? Pin
Saul Johnson22-Sep-08 21:12
Saul Johnson22-Sep-08 21:12 
AnswerRe: WebBrowser Drag/Drop Support? Pin
jzonthemtn23-Sep-08 0:26
jzonthemtn23-Sep-08 0:26 
GeneralRe: WebBrowser Drag/Drop Support? Pin
Saul Johnson24-Sep-08 20:47
Saul Johnson24-Sep-08 20:47 
GeneralRe: WebBrowser Drag/Drop Support? Pin
albertjian18-Mar-10 22:32
albertjian18-Mar-10 22:32 
Questionhow to list the datas in combobox or listbox? Pin
dileep.arangod22-Sep-08 20:54
dileep.arangod22-Sep-08 20:54 
AnswerRe: how to list the datas in combobox or listbox? Pin
Ashfield22-Sep-08 21:11
Ashfield22-Sep-08 21:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.