Plse help me..
-
I hv downloaded following codes to save image from vb.net 2005 to Mysql. Private Sub cmdSaveDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSaveDB.Click If picShowPicture.Image Is Nothing Then Exit Sub Dim ms As MemoryStream = New MemoryStream picShowPicture.Image.Save(ms, ImageFormat.Jpeg) Dim bytBLOBData(ms.Length - 1) As Byte ms.Position = 0 ms.Read(bytBLOBData, 0, ms.Length) Dim prm As New MySql.Data.MySqlClient.MySqlParameter("@BLOBData", _ MySql.Data.MySqlClient.MySqlDbType.Blob, _ bytBLOBData.Length, ParameterDirection.Input, False, _ 0, 0, Nothing, DataRowVersion.Current, bytBLOBData) Dim ConnectionString As String = "SERVER=localhost;" & _ "PORT=3306;DATABASE=pictureDB;User Id=root;" & _ "PASSWORD=pass;" Dim QueryString As String = "INSERT INTO blobtest ( BLOBData ) VALUES ( @BLOBData )" MsgBox(QueryString) Dim myConnection As New MySqlConnection(ConnectionString) Dim myCommand As New MySqlCommand(QueryString) myCommand.Connection = myConnection myCommand.Parameters.Add(prm) 'Open the connection myConnection.Open() 'Execute the query myCommand.ExecuteNonQuery() 'Close the connection myConnection.Close() End Sub But it is giving me a error saying imageformat is not declared.. How to solve it.. Plse help me..
-
I hv downloaded following codes to save image from vb.net 2005 to Mysql. Private Sub cmdSaveDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSaveDB.Click If picShowPicture.Image Is Nothing Then Exit Sub Dim ms As MemoryStream = New MemoryStream picShowPicture.Image.Save(ms, ImageFormat.Jpeg) Dim bytBLOBData(ms.Length - 1) As Byte ms.Position = 0 ms.Read(bytBLOBData, 0, ms.Length) Dim prm As New MySql.Data.MySqlClient.MySqlParameter("@BLOBData", _ MySql.Data.MySqlClient.MySqlDbType.Blob, _ bytBLOBData.Length, ParameterDirection.Input, False, _ 0, 0, Nothing, DataRowVersion.Current, bytBLOBData) Dim ConnectionString As String = "SERVER=localhost;" & _ "PORT=3306;DATABASE=pictureDB;User Id=root;" & _ "PASSWORD=pass;" Dim QueryString As String = "INSERT INTO blobtest ( BLOBData ) VALUES ( @BLOBData )" MsgBox(QueryString) Dim myConnection As New MySqlConnection(ConnectionString) Dim myCommand As New MySqlCommand(QueryString) myCommand.Connection = myConnection myCommand.Parameters.Add(prm) 'Open the connection myConnection.Open() 'Execute the query myCommand.ExecuteNonQuery() 'Close the connection myConnection.Close() End Sub But it is giving me a error saying imageformat is not declared.. How to solve it.. Plse help me..
Please read on how to ask good questions, 'please help me' is not a reasonable header. Everyone here wants help. Which line gives the error ? As the word 'ImageFormat' does not appear in the code you pasted, I assume it's not one of these lines ? Have you tried using the debugger ? This is what happens if you copy code off the web at random, articles and code snippets are great, but you need to take the time to understand them before you use them.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
I hv downloaded following codes to save image from vb.net 2005 to Mysql. Private Sub cmdSaveDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSaveDB.Click If picShowPicture.Image Is Nothing Then Exit Sub Dim ms As MemoryStream = New MemoryStream picShowPicture.Image.Save(ms, ImageFormat.Jpeg) Dim bytBLOBData(ms.Length - 1) As Byte ms.Position = 0 ms.Read(bytBLOBData, 0, ms.Length) Dim prm As New MySql.Data.MySqlClient.MySqlParameter("@BLOBData", _ MySql.Data.MySqlClient.MySqlDbType.Blob, _ bytBLOBData.Length, ParameterDirection.Input, False, _ 0, 0, Nothing, DataRowVersion.Current, bytBLOBData) Dim ConnectionString As String = "SERVER=localhost;" & _ "PORT=3306;DATABASE=pictureDB;User Id=root;" & _ "PASSWORD=pass;" Dim QueryString As String = "INSERT INTO blobtest ( BLOBData ) VALUES ( @BLOBData )" MsgBox(QueryString) Dim myConnection As New MySqlConnection(ConnectionString) Dim myCommand As New MySqlCommand(QueryString) myCommand.Connection = myConnection myCommand.Parameters.Add(prm) 'Open the connection myConnection.Open() 'Execute the query myCommand.ExecuteNonQuery() 'Close the connection myConnection.Close() End Sub But it is giving me a error saying imageformat is not declared.. How to solve it.. Plse help me..
-
You have to import the namespaces that the code uses. If you look up ImageFormat in the documentation, you see that it's in the System.Drawing.Imaging namespace.
Despite everything, the person most likely to be fooling you next is yourself.