Query MySQL Database in ASP.net


                                                        
1
2
3 <%@ Page Language="VB" %>
4 <%@ import Namespace="System.Data.Odbc" %>
5
6 <script runat="server">
7
8 Public Sub Page_Load()
9 Dim mySelectQuery As String = "SELECT * FROM tblTest"
10 Dim myConnection As New OdbcConnection("DSN=_mysqlConn")
11
12
13 Dim myCommand As New OdbcCommand(mySelectQuery, myConnection)
14 myConnection.Open()
15 Dim myReader As OdbcDataReader = myCommand.ExecuteReader()
16 Try
17 While myReader.Read()
18 response.write (myReader("name") & "
")
19 End While
20 Finally
21 ' always call Close when done reading.
22 myReader.Close()
23 ' always call Close when done with connection.
24 myConnection.Close()
25 End Try
26 End Sub
27
28 script>
29 <html>
30 <head>
31 head>
32 <body>
33 <form runat="server">
34
35 form>
36 body>
37 html>
38
39
40

  • 0 کاربر این را مفید یافتند
آیا این پاسخ به شما کمک کرد؟

مقالات مربوطه

Sample Code on Sending Email using ASP.NET 1

Our mail server is configured with SMTP authentication and all your code need to use SMTP...

Sample Code on how to send email using ASP.NET 2

For ASP.NET 2 you no longer using System.Web.Mail, but you will be using System.Net.Mail and the...