473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Am a newbie in using connection strings in code.S'one explain relevance of each line

8
This is the code I wish to have explained what each line stands for. Am using VB6 and MYSQL, Win XP.

Private Sub Class_Initialize()
On Error GoTo errlabel
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient 'is this line relevant? in which Context?
db.Open "PROVIDER=MSDASQL;dsn=KWTSYS;uid=root;pwd=;"

Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "", db, adOpenStatic, adLockOptimistic

DataMembers.Add "Primary"
Exit Sub
'I understand the rest...............................
errlabel:
If Err.Number = 2147467259 Then
MsgBox "Cannot connect to the database server,please start MYSQL server", vbCritical, "Connection Error"
Exit Sub
ElseIf Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Sep 14 '06 #1
1 1527
sashi
1,754 Expert 1GB
Hi there,

This part of the code simple means to trap error no. "2147467259", in VB error no. "0" simple means there is no error at all, the code is written to prompt an error message when "Run time error -2147467259" occurs, hope u understand.. :)

This is the code I wish to have explained what each line stands for. Am using VB6 and MYSQL, Win XP.

Private Sub Class_Initialize()
On Error GoTo errlabel
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient 'is this line relevant? in which Context?
db.Open "PROVIDER=MSDASQL;dsn=KWTSYS;uid=root;pwd=;"

Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "", db, adOpenStatic, adLockOptimistic

DataMembers.Add "Primary"
Exit Sub
'I understand the rest...............................
errlabel:
If Err.Number = 2147467259 Then
MsgBox "Cannot connect to the database server,please start MYSQL server", vbCritical, "Connection Error"
Exit Sub
ElseIf Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Sep 14 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: JWM | last post by:
I am trying to implement Oracle connection pooling for the following code, which was written by someone else. Here is my main question -- this java file creates code that is executed every hour,...
5
by: reddy | last post by:
I am trying to insert a node into an XMLFile. using XMLTextwriter. My Question is Is it possible to do without using XMLDocument. Because its loading all the the file into memory. I just want to...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
12
by: chadlupkes | last post by:
I've been trying to create a simple (I hope) PHP application to send emails to a membership list. I have yet to successfully connect to my database to pull the names and email addresses. I'm...
2
by: kelly | last post by:
Hi, I don't have a code to show you, what I need are references or algorithms so that I'm in a right track. By the way, thanks for introducing me the array or arrays. Now I can continue my...
71
by: desktop | last post by:
I have read in Bjarne Stroustrup that using malloc and free should be avoided in C++ because they deal with uninitialized memory and one should instead use new and delete. But why is that a...
2
by: Johnson | last post by:
I'm trying to fix a "sub optimal" situation with respect to connection string management. Your thoughtful responses will be appreciated. I just started with a new client who has a bunch of legacy...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.