Click here to Skip to main content
15,915,873 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionValidationGroup= doesn't fire in control Pin
Brendan Vogt7-Jun-07 4:55
Brendan Vogt7-Jun-07 4:55 
QuestionDB connection location. Pin
sergeyv20027-Jun-07 4:38
sergeyv20027-Jun-07 4:38 
AnswerRe: DB connection location. Pin
Not Active7-Jun-07 4:57
mentorNot Active7-Jun-07 4:57 
Questionexport datagrid to excel from a popup window Pin
D.Sridhar7-Jun-07 3:57
D.Sridhar7-Jun-07 3:57 
AnswerRe: export datagrid to excel from a popup window Pin
l0kke7-Jun-07 4:24
l0kke7-Jun-07 4:24 
GeneralRe: export datagrid to excel from a popup window Pin
D.Sridhar7-Jun-07 4:41
D.Sridhar7-Jun-07 4:41 
GeneralRe: export datagrid to excel from a popup window Pin
D.Sridhar7-Jun-07 7:06
D.Sridhar7-Jun-07 7:06 
QuestionUploading problem Pin
ASPnoob7-Jun-07 3:04
ASPnoob7-Jun-07 3:04 
Hi, I have tried to upload a file to a MySQL database for a week now and still have problems. Would you please check to see what is causing the exception "Invalid cast from System.String to System.Byte[]." The following are my code for uploading a file to the database. I would really like to know why its giving me that error message, thank you in advance for your help.
  ----------------------------------------------------------------------------------------------------------------------------------------    
 |  Field              |   Type              |   Null         |   Key           |  Default                              |   Extra                     |
----------------------------------------------------------------------------------------------------------------------------------------
 | docID              | int(11)             | NO           |   PRI            |  NULL                                 | AUTO_INCREMENT   |
 |

 | docTitle          | varchar(30)      | NO           |                    |    NULL                               |                                 |
 |

 | docContent        | MediumBlob     | NO           |                    |    NULL                               |                                 |
 |

 | docDate         | timestamp        | NO           |                    |    CURRENT_TIMESTAMP     |                                |
 |

 | docType        | varchar(15)       | NO           |                    |    NULL                               |                                |
----------------------------------------------------------------------------------------------------------------------------------------


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 strFileEx 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
            strFileEx = Right(txtFileContents.PostedFile.FileName, 4)
            Select Case strFileEx.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.Text)           
            cmdInsert.Parameters["@docContent"].Values =arrFile
            
            myConnection.Open()
            cmdInsert.ExecuteNonQuery()
            myConnection.Close()
        End If

    End Sub
End Class

AnswerRe: Uploading problem Pin
Chetan Ranpariya7-Jun-07 3:29
Chetan Ranpariya7-Jun-07 3:29 
QuestionRe: Uploading problem [modified] Pin
ASPnoob7-Jun-07 8:05
ASPnoob7-Jun-07 8:05 
AnswerRe: Uploading problem Pin
Chetan Ranpariya7-Jun-07 20:27
Chetan Ranpariya7-Jun-07 20:27 
GeneralRe: Uploading problem [modified] Pin
ASPnoob7-Jun-07 22:18
ASPnoob7-Jun-07 22:18 
GeneralRe: Uploading problem Pin
ASPnoob8-Jun-07 16:03
ASPnoob8-Jun-07 16:03 
Questioncookie deletion Pin
deepalititi7-Jun-07 2:42
deepalititi7-Jun-07 2:42 
AnswerRe: cookie deletion Pin
Sylvester george7-Jun-07 2:57
Sylvester george7-Jun-07 2:57 
QuestionHow to insert item in RadioButtonList using java script in asp.net Pin
Rajesh_K_Sharma7-Jun-07 2:19
Rajesh_K_Sharma7-Jun-07 2:19 
AnswerRe: How to insert item in RadioButtonList using java script in asp.net Pin
Sathesh Sakthivel7-Jun-07 2:28
Sathesh Sakthivel7-Jun-07 2:28 
GeneralRe: How to insert item in RadioButtonList using java script in asp.net Pin
Rajesh_K_Sharma7-Jun-07 4:57
Rajesh_K_Sharma7-Jun-07 4:57 
GeneralRe: How to insert item in RadioButtonList using java script in asp.net Pin
revi227-Jun-07 5:01
revi227-Jun-07 5:01 
GeneralRe: How to insert item in RadioButtonList using java script in asp.net Pin
Guffa7-Jun-07 13:07
Guffa7-Jun-07 13:07 
GeneralRe: How to insert item in RadioButtonList using java script in asp.net Pin
Sathesh Sakthivel7-Jun-07 16:39
Sathesh Sakthivel7-Jun-07 16:39 
Questiontime zone [modified] Pin
Mohammad Daba'an7-Jun-07 1:29
Mohammad Daba'an7-Jun-07 1:29 
AnswerRe: time zone Pin
Sylvester george7-Jun-07 2:43
Sylvester george7-Jun-07 2:43 
GeneralRe: time zone Pin
Mohammad Daba'an7-Jun-07 14:00
Mohammad Daba'an7-Jun-07 14:00 
Questionabout fixed size of control Pin
Nilesh Mitra7-Jun-07 1:24
Nilesh Mitra7-Jun-07 1:24 

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.