| | |
Connecting ASP.Net to MySQL and storing images.
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2008
Posts: 34
Reputation:
Solved Threads: 0
Hi guys,
I've been using asp.net 2.0 over the past 2 years making simple web applications but have never used it with MySQL.
I've been asked to create a website for a relative. The site will be a vehicle leasing company. After speaking to owner and understanding his requirements i will be able to create the majority of it with no problem. However, as its a leasing company vehicles will need to be added/deleted on a regular basis so i assume having a database (MySQL) connected to the site will be the easiest way to achieve this. Furthermore, it would make sense to have an image of the vehicle too, will MySQL be able to retrieve the images?
I have Visual Studio 2005 installed as well as MySQl 5.1, MySQL Connector/ODBC 5.1 and the MySQL Connector Net 6.0.3.
I have created a new project and placed the following code in my source file:
Originally a number of errors were produced however after some bug fixing these were eliminated by placing the 'MySql.Data.dll' within the AppData folder as well as adding a reference to this file via the Windows tab - Add Refrence..
After compling the file zero errors/warning are shown, however, when i open the file within the web the contents of the database does not appear. I have double checked that there is data in the db declared.
Apologies for the long message, but i thought the more info the better..
Please can anyone see what i've done wrong??
Thanks.
I've been using asp.net 2.0 over the past 2 years making simple web applications but have never used it with MySQL.
I've been asked to create a website for a relative. The site will be a vehicle leasing company. After speaking to owner and understanding his requirements i will be able to create the majority of it with no problem. However, as its a leasing company vehicles will need to be added/deleted on a regular basis so i assume having a database (MySQL) connected to the site will be the easiest way to achieve this. Furthermore, it would make sense to have an image of the vehicle too, will MySQL be able to retrieve the images?
I have Visual Studio 2005 installed as well as MySQl 5.1, MySQL Connector/ODBC 5.1 and the MySQL Connector Net 6.0.3.
I have created a new project and placed the following code in my source file:
asp.net Syntax (Toggle Plain Text)
<%@ Page Language="VB" Debug="true" AutoEventWireup="false" CodeFile="DBConnection.aspx.vb" Inherits="DBConnection" %> <%@ Import Namespace = "System.Data" %> <%@ Import Namespace = "MySql.Data.MySqlClient" %> <script language="VB" runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Dim myConnection As MySqlConnection Dim myDataAdapter As MySqlDataAdapter Dim myDataSet As DataSet Dim strSQL As String 'Dim iRecordCount As Integer myConnection = New MySqlConnection("server=localhost; user id=15secs; password=password; database=mydatabase; pooling=false;") strSQL = "SELECT * FROM mytable;" myDataAdapter = New MySqlDataAdapter(strSQL, myConnection) myDataSet = New DataSet() myDataAdapter.Fill(myDataSet, "mytable") MySQLDataGrid.DataSource = myDataSet MySQLDataGrid.DataBind() End Sub </script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>S Q L Connection</title> </head> <body> <form id="form1" runat="server"> <div> <asp:DataGrid id="MySQLDataGrid" runat="server" /> </div> </form> </body> </html>
Originally a number of errors were produced however after some bug fixing these were eliminated by placing the 'MySql.Data.dll' within the AppData folder as well as adding a reference to this file via the Windows tab - Add Refrence..
After compling the file zero errors/warning are shown, however, when i open the file within the web the contents of the database does not appear. I have double checked that there is data in the db declared.
Apologies for the long message, but i thought the more info the better..
Please can anyone see what i've done wrong??
Thanks.
Last edited by peter_budo; May 10th, 2009 at 9:33 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
![]() |
Similar Threads
- How to configure GD (PHP)
Other Threads in the ASP.NET Forum
- Previous Thread: Filter cascading dropdown lists
- Next Thread: Visual Studio 2005 - Credentials for Remote Site Login
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions compatible content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formview gridview gudi iis javascript list listbox login menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice wizard xsl





