Click here to Skip to main content
15,920,383 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: AJAX UpdatePanel related Pin
Venk25912-Jun-07 18:32
Venk25912-Jun-07 18:32 
GeneralRe: AJAX UpdatePanel related Pin
larree1112-Jun-07 19:17
larree1112-Jun-07 19:17 
QuestionI NEED SOURCE FORUM ASP.NET WITH C# Pin
suchon_phuong7-Jun-07 17:35
suchon_phuong7-Jun-07 17:35 
AnswerRe: I NEED SOURCE FORUM ASP.NET WITH C# Pin
Christian Graus7-Jun-07 18:11
protectorChristian Graus7-Jun-07 18:11 
Questionhow can I get the next item? Pin
lockepeak7-Jun-07 16:52
lockepeak7-Jun-07 16:52 
AnswerRe: how can I get the next item? Pin
Arun.Immanuel7-Jun-07 17:51
Arun.Immanuel7-Jun-07 17:51 
AnswerRe: how can I get the next item? Pin
Christian Graus7-Jun-07 18:12
protectorChristian Graus7-Jun-07 18:12 
QuestionInvalid cast from System.String to System.Byte[ ] [modified] Pin
ASPnoob7-Jun-07 16:41
ASPnoob7-Jun-07 16:41 
Hi, I get the following error message when I run my application in the browser.

"Invalid cast from System.String to System.Byte[ ]"

I have changed cmdInsert.Parameters.Add("@docContent",OdbcType.Text) to

cmdInsert.Parameters.Add("@docContent",OdbcType.Binary)

like someone had suggested, but it still does not work. I have checked other variables for type mismatch but didn't find any. If you see anything at all wrong with my code please point it out. I would really be grateful if you can show me what is causing VS2003 to throw the exception. Thank you in advance for your help.

The following is my code to help you better understand my situation.

Imports System.IO
Imports System.Data.Odbc
Public Class Upload
    Inherits System.Web.UI.Page

 Private Sub Submit1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit1.Click
        Dim strFileExtension As String
        Dim StrFileType As String
        Dim intFileLen As Integer
        Dim objStream As Stream
        Dim strInsert As String
        Dim myConnection As OdbcConnection
        Dim cmdInsert As OdbcCommand


        If Not IsNothing(txtFileContents.PostedFile) Then
            'Determines File Type
            strFileExtension = Right(txtFileContents.PostedFile.FileName, 4)
            Select Case strFileExtension.ToLower
                Case ".doc"
                    StrFileType = "doc"
                Case ".ppt"
                    StrFileType = "ppt"
                Case ".htm"
                    StrFileType = "htm"
                Case ".html"
                    StrFileType = "html"
                Case ".txt"
                    StrFileType = "txt"
                Case Else
                    StrFileType = "jpg"
            End Select
            'Grab the content of uploaded file
            intFileLen = txtFileContents.PostedFile.ContentLength
            Dim arrFile(intFileLen) As Byte
            objStream = txtFileContents.PostedFile.InputStream
            objStream.Read(arrFile, 0, intFileLen)


            'Add UpLoaded file to a database
            myConnection = New OdbcConnection("Provider=MySQLProv; Data Source=Data;User Id=myID;Password=myPWD")
            strInsert = "INSERT into QUsers (docTitle,docContent,docDate,docType) values (?,?,?,?,?)"
            cmdInsert = new odbcCommand(strInsert,myConnection)
            
            cmdInsert.Parameters.Add("@docID",OdbcType.int,30)           
            cmdInsert.Parameters["@docID"].Values =""

            cmdInsert.Parameters.Add("@docDate", OdbcType.TimeStame,14)             
            cmdInsert.Parameters["@docDate"].Values = DateTime.Now.ToShortDateString()

            cmdInsert.Parameters.Add("@docTitle", OdbcType.Varchar,30  )
            cmdInsert.Parameters["@docTitle"].Values = txtFileTitle.Text       
            
            cmdInsert.Parameters.Add("@docType", OdbcType.Varchar,30)
            cmdInsert.Parameters["@docType"].Values =StrFileType

            cmdInsert.Parameters.Add("@docContent",OdbcType.Binary)           
            cmdInsert.Parameters["@docContent"].Values =arrFile
            
            myConnection.Open()
            cmdInsert.ExecuteNonQuery()
            myConnection.Close()
        End If

    End Sub
End Class





-- modified at 23:26 Thursday 7th June, 2007
AnswerRe: Invalid cast from System.String to System.Byte[ ] Pin
ASPnoob8-Jun-07 16:01
ASPnoob8-Jun-07 16:01 
QuestionIDENTITY_INSERT Pin
seemamltn7-Jun-07 15:30
seemamltn7-Jun-07 15:30 
AnswerRe: IDENTITY_INSERT Pin
Sathesh Sakthivel7-Jun-07 16:46
Sathesh Sakthivel7-Jun-07 16:46 
Question.net documentation Pin
haytham_mohammad7-Jun-07 14:11
haytham_mohammad7-Jun-07 14:11 
AnswerRe: .net documentation Pin
Colin Angus Mackay7-Jun-07 14:26
Colin Angus Mackay7-Jun-07 14:26 
QuestionFile retrive from DataBase Pin
seemamltn7-Jun-07 13:23
seemamltn7-Jun-07 13:23 
AnswerRe: File retrive from DataBase [modified] Pin
ASPnoob7-Jun-07 17:02
ASPnoob7-Jun-07 17:02 
QuestionError message Pin
seemamltn7-Jun-07 11:48
seemamltn7-Jun-07 11:48 
AnswerRe: Error message Pin
Christian Graus7-Jun-07 12:39
protectorChristian Graus7-Jun-07 12:39 
QuestionCustom WSS 3.0 aspx page Pin
archangel7177-Jun-07 11:29
archangel7177-Jun-07 11:29 
Questionhow-to select a specific row in gridview C# Pin
pat3d27-Jun-07 9:55
pat3d27-Jun-07 9:55 
QuestionConverting Request object to WebRequest in asp.net Pin
amitar277-Jun-07 9:19
amitar277-Jun-07 9:19 
AnswerRe: Converting Request object to WebRequest in asp.net Pin
Not Active7-Jun-07 9:25
mentorNot Active7-Jun-07 9:25 
GeneralRe: Converting Request object to WebRequest in asp.net Pin
amitar277-Jun-07 11:03
amitar277-Jun-07 11:03 
GeneralRe: Converting Request object to WebRequest in asp.net Pin
Not Active7-Jun-07 15:13
mentorNot Active7-Jun-07 15:13 
QuestionDisplaying SSRS 2005 via Web Services in ASP.NET Pin
BigBlueEye7-Jun-07 6:22
BigBlueEye7-Jun-07 6:22 
Questionhow to run in linux...? Pin
Balaji.K7-Jun-07 6:08
Balaji.K7-Jun-07 6:08 

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.