.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Imran Ghani
Post New Web Links

Read image from MySQL with ODBC

Posted By:      Posted Date: September 29, 2010    Points: 0   Category :ASP.Net
 

Hello everyone. I have a problem that I can't figure out. I shall read an images from a column in a MySQL database. I use a simple aspx page and the codebehind file with the code below.

It is ok to read the image if I don't use any parameter value in the where clause, but if I use it, nothing is returned. I don't know if I have done anything wrong in the code. I have also tried to set a proper value on the parameter.value without success. So my conclusion is that the parameter sertup is wrong in my code. Any ideas someone?

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim PictureID As Integer = Convert.ToInt32(Request.QueryString("id"))

        'Connect to the database and bring back the image contents & MIME type for the specified picture

        Using myConnection As New OdbcConnection("Driver={MySQL ODBC 5.1 Driver};server=localhost;uid=;pwd={};database=xxx;port=3306")

 

            Const SQL As String = "SELECT blobdata FROM tblblogg WHERE id = @PictureID"  ---> If I change this parameter to a existing id it works

   &nbs


View Complete Post


More Related Resource Links

passing parameter using ODBC - mysql

  
Dear All, I'm having problem on passing parameter on odbc because it's not working at all.  I tried this using sql and I have no problem at all. All are working fine.  Is there a different syntax on odbc?  Here's my code: Private Sub BindDetails() ' Obtain the index of the selected row Dim selectedRowIndex As Integer = GridEmployee.SelectedIndex ' Read the employee ID Dim IDNumber As Integer = GridEmployee.DataKeys(selectedRowIndex).Value ' Define data objects Dim conn As OdbcConnection Dim comm As OdbcCommand Dim reader As OdbcDataReader Dim connectionString As String = _ ConfigurationManager.ConnectionStrings( _ "mysqlconn").ConnectionString ' Initialize connection conn = New OdbcConnection(connectionString) ' Create command comm = New OdbcCommand("SELECT employee.IDNumber, employee.EmployeeID, project.ProjectName, team.TeamName, employee.Username, employee.`Password`, employee.LastName, employee.FirstName, employee.MiddleName, employee.NickName, employee.EmailAddress, employee.DateHired, employee.LengthService, employee.RegularizationDate, employeestatus.EmployeeStatusName, employee.Birthdate, employee.Mobile1, employee.Mobile2, employee.Phone1, employee.Address, employee.Colleg

ADO fast, ODBC not so much with mysql odbc 5.1

  
Hello-   I have been trying to convert our internal webpage from asp to ASP.NET with .NET 4.0. Some of our pages pull from multiple tables/databases to comprise a single page. The original asp pages connecting to the database are LIGHTNING fast, However the new pages using the MySQL ODBC 5.1 drivers fail to come even close to the asp pages. Average load time for an ASP.NET is about 92000ms., ASP load time about 8ms. Here is what I've tried/noticed 1. Regardless of setting ViewState,Debug to (true/false) in page or web.config makes no difference, load time stays about 6000ms per call to database 2. We have two Servers (web and main), ASP pages take about the same time (8ms) to load from each/both servers, ASP.NET pages take about 8ms(main) from one and about 12000ms(web) from the other 3. I tried to trace the ODBC driver, but to no avail (don't have admin access to force). Using the TEST button through the dialog box has about 5sec delay from (web) and instant feedback from (main) 4. Checked all the code calls to make sure that for every open there is a close, same slow result from ODBC 5. Tried to have only one open and one close call to the DB and many reads in between, same result: slow performance. 6. I have read the article about optimizing my code through the use of caching etc... I don't believe this applies to my s

Read from and write to Data Base an Image

  
Hi guys. How can I show a saved picturs from data base into a Image control? And how can I save an Image from my web page into data base? (with less code pleeeaaase.)

WCF: Read file system image and return image thru wcf

  

Hi,

I have a service which reads an image stored in the database. I want to be able to read an image stored on the file system and return that back to the requestor, is that possible?

Thanks for your help! :)

Moneka


How to fix "ERROR [08S01] [MySQL][ODBC 5.1 Driver][mysqld-5.1.46-community]MySQL server has gone awa

  

Hi Experts ,

I have hosted my web application into server . I got below error on and off but when i refresh the page , the error disappear . Im unable to figure out what is the problem because the error is normal happen after using the application about 10 to 20 mins . But when i run in localhost , there is no problem at all .  

I read lot of articles and testing on it but still failed .  Pls help . Im using asp.net C# and mysql .

Million Thanks ..

 

 

-----------------------------------------------------------------------------------------------------

ERROR [08S01] [MySQL][ODBC 5.1 Driver][mysqld-5.1.46-community]MySQL server has gone away

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.Odbc.OdbcException: ERROR [08S01] [MySQL][ODBC 5.1 Driver][mysqld-5.1.46-community]MySQL server has gone away

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and lo

ODBC text driver doesn't read columns containing double quotes

  

Hello,

I'm having some trouble with importing some information from a delimited text file into an SQL database. I made a DSN for the file using the  Microsoft ODBC driver. It reads most of the data fine. I can get most of it into the database, or using Excel I can display it in a table.

This is a regular text file, the delimiter is a "|" character. Some of the data has double quotes embedded in it. Every time it hits one of these double quotes, the rest of the information on that line are ignored.Then it will move on to the next line in the file.

Is there a way to set up the driver to read these quotes somehow, or to just ignore them?


Read DBF file using odbc

  

Dear All,

I try to read a DBF file by using odbc. What I want is just read all record in DBF file and load it into datatable

When I search the solution in Internet, I found the solution below :

Public Function ImportDBF(ByVal sPathName As String, ByVal sFileName As String) As DataTable
        Try
            Dim oConn As New System.Data.Odbc.OdbcConnection()
            oConn.ConnectionString = "Driver={Microsoft dBase Driver (*.dbf)};SourceType=DBF;SourceDB=" & sPathName & ";Exclusive=No; NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;"
            oConn.Open()
            Dim oCmd As System.Data.Odbc.OdbcCommand = oConn.CreateCommand()
            oCmd.CommandText = "SELECT * FROM " & sPathName & sFileName
            Dim dt As New DataTable()
            dt.Load(oCmd.ExecuteReader())
            oConn.Close()

            Return dt
        Catch ex As Exception
            Throw New Exception(ex.Message)
        End Try
    End Function

Note : sPathName is folder where DBF file is saved, and sFileName is DBF filename


The code above running well in debugging mode (ASP.NET Development Server), but after I publish to IIS, I got this error message :

"An error occure at : ERROR [HY000] [Microsoft][ODBC dBase Driver] The search key was

Drawing and saving a vector image (emf/wmf or anything MSWord/PPT can read)

  

Hi! I've been tasked with generating graphs of data as images for the purpose of importing into MS Word documents and Powerpoint presentations.

I've done it using GIF images, but I'd really like to use a vector format, so they can be scaled in the document without losing quality, and of course keeping the document size down as there's lots of them.

MS Word and Powerpoint can import EMF, WMF and CGM formats, but I have no idea how to generate those in .NET.

Does anyone have some pointers for me to get started creating say EMF files from .NET?  I've looked all over the net and can't find much at all about it... I've gathered it's a job for GDI+, but can't find sample code or anything for .NET.

Many thanks!


Connecting BCS to ODBC / MySQL sources in SharePoint Designer 2010

  
Hi,

Internally we are trying to migrate our MOSS 2007 solution to SP2010 in readiness for RTM.  So far, minus a few tweaks everything has been successful.

However we have a requirement to connect to a MySQL database.  It would be great to do this within SPD 2010 rather than via Visual Studio (which I suspect is the only way).

Does any body have any ideas or suggestions regarding this?

MySql.Data.MySqlClient.MySqlException: Invalid attempt to access a field before calling Read()

  

I'm getting the Following Error.

 Invalid attempt to access a field before calling Read()
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: MySql.Data.MySqlClient.MySqlException: Invalid attempt to access a field before calling Read()

Source Error:


Line 132:        catch (Exception ex)
Line 133:        {
Line 134:            throw (ex);
Line 135:        }
Line 136:        finally
 

 

This error comes sometime and sometimes it doesnot come.

 

I tried to serach on mysql.com the same bug has been posted but no solution.

 


 


Read Image from excel file Issue

  

Hello every one.I'm trying to read images from an excel file using OleDbDataReader. My excel file has 6 columns of data, the first 5 are all text but the last is image. While I'm reading the record, It's doing fine on the first 5 columns but return me with a "blank" for the sixth column.

Here is my demonistration code:


  protected void btnImportExcelFile_Click(object sender, EventArgs e)
    {

      string strConn;
      strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
      "Data Source=C:\\exceltest.xls;" +
      "Extended Properties=Excel 8.0;";
      
      OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM Sheet1$]", strConn);

      DataSet myDataSet = new DataSet();
      myCommand.Fill(myDataSet, "Sheet1");
      DataGrid1.DataSource = myDataSet.Tables["Sheet1"].DefaultView;
      DataGrid1.DataBind();

    }

ASPX Code
------------------------------------
<asp:Button ID="btnImportExcel

MySql.Data.MySqlClient.MySqlException: Invalid attempt to access a field before calling Read()

  

I'm getting the Following Error.

 Invalid attempt to access a field before calling Read()
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: MySql.Data.MySqlClient.MySqlException: Invalid attempt to access a field before calling Read()

Source Error:


Line 132:        catch (Exception ex)
Line 133:        {
Line 134:            throw (ex);
Line 135:        }
Line 136:        finally
 

 

This error comes sometime and sometimes it doesnot come.

 

I tried to serach on mysql.com the same bug has been posted but no solution.

 


 


Accessing MySQL Data using ODBC w/ BDC Definition Editor

  

Hello everyone.

Background: I'm a computer science student doing some work for a non-for-profit, and have minimal experience with SP 2007, ODBC, etc.

Overview: I'm trying to create a BDC definition file using the definition editor (found in the SDK), rather than editing a template XML manually. I found this thread to be fairly helpful in getting me started on what seems to be the right path: http://social.msdn.microsoft.com/Forums/en/sharepointbdc/thread/833a9583-5f4c-4ed9-b9c8-f5834b790375

In order to establish a connection to the remotely hosted MySQL database I must provide an ODBC source for the client user/system, correct?

 My questions are: 

  • How does using ODBC affect things once I upload the ADF to the Shared Services Provider (SSP)? Do I now need to provide a duplicate ODBC Source on the server hosting sharepoint for the BDC to connect to the database? Apologies if I am not understanding this correctly.
  • If the above process is correct, how might I expect this process to change for sharepoint 2010? The organization is looking to roll-out SP2010

Built-in Functions - Text and Image Functions in SQL Server

  
Text and image functions operate on TEXT, NTEXT and IMAGE data types. These data types are deprecated with SQL Server 2005 and should be replaced by VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) when possible. Alternatively you can also consider storing large string values using XML data type. Text and image functions are nondeterministic.

Future versions of SQL Server will not support TEXT, NTEXT and IMAGE data types. Columns with TEXT / NTEXT data type do not support commonly used string functions such as LEN, LEFT, RIGHT, etc. Furthermore, due to the large size of TEXT data you''re likely to see performance issues if you store such data in the database. However, at times you can''t help but use the TEXT / NTEXT / IMAGE data types (for example when supporting 3rd party databases when you cannot change the schema) - this is when text and image functions come in handy.

Program for Format Conversion of An Image

  
.NET provides extensive support for image conversion. Any image can be processed from one format to another. Most common formats to which .NET have support for are .BMP, .EMF, .GIF, .ICO, .JPG, .PNG, .TIF and .WMF.

Configuring Profile Image Export in SharePoint 2010

  
It's no secret that I am thrilled with the new social features of SharePoint 2010. I am most excited about the new Profile Picture handling. I strongly believe that the more we can show the faces of our colleagues to one another the more connected we will feel. Clearly Microsoft feels that way as witnessed by the many features that make use of the Profile Image like the Activity Feed and Colleagues list

Built-in Functions - Text and Image Functions

  
Text and image functions operate on TEXT, NTEXT and IMAGE data types. These data types are deprecated with SQL Server 2005 and should be replaced by VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) when possible. Alternatively you can also consider storing large string values using XML data type. Text and image functions are nondeterministic.
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend