|
Technical Interview Questions
Visual Basic Interview Question
.NET Web Interview Questions
.NET
Interview Questions
C#
Interview Questions
.........More
Source Codes
Asp .NET Source Codes
Asp VB Script Source Codes
.........More
Soft Skills
Communication Skills
Leadership Skills
.........More
|
|
Asp/VB Script Source Codes
Connect to a MySQL database
<P>In this example we will show you how to connect to a MySQL database .</P>
<P>Create a database like this. </P>
<P>CREATE DATABASE example;<BR>USE example;</P>
<P>CREATE TABLE example(url VARCHAR(40) , description TEXT);</P>
<P>INSERT INTO example VALUES('http://www.google.com' , ' The best search
engine');<BR>INSERT INTO example VALUES('http://www.beginnersphp.co.uk' , 'top
notch php site');<BR>INSERT INTO example
VALUES('http://www.myscripting.com','Scripting resources galore here');<BR></P>
<P>This is a simple example which will display links on your page , now lets
move on to the script</P>
<P>In the example below remember and change the uid and pwd to your own username
and password . </P>
<P><%<BR>'declare some constants that are used in the script<BR>Dim
adOpenForwardOnly , adLockReadOnly , adCmdTable<BR>adOpenForwardOnly = 0<BR>adLockReadOnly
=1 <BR>adCmdTable =2<BR>'variable declaration in here<BR>Dim objConn , objRS<BR>'create
our objects<BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>Set
objRS = Server.CreateObject("ADODB.Recordset")<BR>'connect to the MySQL example
database<BR>objConn.Open "driver={MySQL};server=localhost;uid=username;pwd=password;database=example"
<BR>'open the example table<BR>objRS.Open "example" , objConn ,
adOpenForwardOnly , adLockReadOnly , adCmdTable<BR>'display all data in the
table<BR>While Not objRS.EOF<BR>Response.Write objRS.Fields("URL") & "&nbsp"<BR>Response.Write
objRS.Fields("description") & "&nbsp"<BR>Response.Write "<p>"<BR>objRS.MoveNext<BR>Wend<BR>'close
recordset<BR>objRS.Close<BR>'destroy all objects<BR>Set objRS = Nothing<BR>Set
onjConn = Nothing<BR>%><BR></P>
<<<----- Return to
Asp/VB Script Source
Code Questions Page.
Have a Question ?
post your questions here. It
will be answered as soon as possible.
Check
Microsoft .Net Interview Questions
for more Microsoft
.Net Interview Questions with Answers.
Check
.Net Database Interview
Questions for more .Net Database Interview Questions with answers
Check
Job Interview Questions
for more Interview Questions with Answers
|