473,394 Members | 1,813 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,394 software developers and data experts.

vb with sql server

How we connect the sql server 2000 to the visual basic
please give me an example code for me.

Thank you for your time and consideration.
Feb 10 '07 #1
2 1178
hariharanmca
1,977 1GB
How we connect the sql server 2000 to the visual basic
please give me an example code for me.

Thank you for your time and consideration.
Public objConnection As New ADODB.Connection

Public Function ConnectToDatabase() As Boolean
On Error GoTo ErrorConnection
If objConnection.State = adStateClosed Then
objConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=strUserId;password=strPassword;Initial Catalog=DatabaseName;Data Source=(local)"
End If
Exit Function
ErrorConnection:
MsgBox " Connection Not Opened. Error" & Err.Number & " - " & Err.Description, vbCritical + vbOKOnly
End Function
Feb 10 '07 #2
Public objConnection As New ADODB.Connection

Public Function ConnectToDatabase() As Boolean
On Error GoTo ErrorConnection
If objConnection.State = adStateClosed Then
objConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=strUserId;password=strPassword;Initial Catalog=DatabaseName;Data Source=(local)"
End If
Exit Function
ErrorConnection:
MsgBox " Connection Not Opened. Error" & Err.Number & " - " & Err.Description, vbCritical + vbOKOnly
End Function


with the use of ADO 2.6 how we connect to the database?
Thank you
Feb 10 '07 #3

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

Similar topics

2
by: Phil | last post by:
I am using a Pascal like language (Wealth-Lab) on W2K and call this server: class HelloWorld: _reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}" _reg_desc_ = "Python Test COM Server"...
6
by: Nathan Sokalski | last post by:
I want to set up SQL Server on Windows XP Pro so that I can use the database capabilities of ASP and IIS. I am probably using some incorrect settings, but I am not sure what they are. Here is what...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
14
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.