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

Use 2 different databases

Hello,

I have created a function which creates a DataTable from a Database.

However, I want to be able to use an Access or aSQL database.

Do I need to create 2 complete different functions?

The method is the same, only the types change.

Here is my code:

' Define connection
Dim connection As New
SqlClient.SqlConnection(connectionString.ToString)

' Define command
Dim command As New SqlClient.SqlCommand
With command
.CommandText = "GetRecords"
.Connection = connection
.CommandType = CommandType.StoredProcedure
End With

' Add command parameters
With command.Parameters
.Add(New SqlClient.SqlParameter("@Value", Value))
End With

connection.Open()
...
Create DataTable
...
connection.Close()

Thanks,

Miguel

Oct 27 '06 #1
1 900
Yes, but not with SQLClient (sql server only)

Consider using the OLEDB methods

Jeff
"shapper" <md*****@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
Hello,

I have created a function which creates a DataTable from a Database.

However, I want to be able to use an Access or aSQL database.

Do I need to create 2 complete different functions?

The method is the same, only the types change.

Here is my code:

' Define connection
Dim connection As New
SqlClient.SqlConnection(connectionString.ToString)

' Define command
Dim command As New SqlClient.SqlCommand
With command
.CommandText = "GetRecords"
.Connection = connection
.CommandType = CommandType.StoredProcedure
End With

' Add command parameters
With command.Parameters
.Add(New SqlClient.SqlParameter("@Value", Value))
End With

connection.Open()
...
Create DataTable
...
connection.Close()

Thanks,

Miguel

Oct 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Minh Tran | last post by:
In order to minimize the number of connection strings I have to use to access different databases on the same Sql Server, I was considering storing all stored procedures in just one database. I...
0
by: Vivek Mehta | last post by:
Hi, I am currently working on a project which requires that our web based application should allow end user to search on various parts and their availability in different regions. Http requests...
1
by: stefari | last post by:
Hi all I have to develop an embedded database using memory FLASH and memory RAM Some tables must be saved in RAM and some tables in FLASH ( RAM and FLASH are two different mounted directories in...
2
by: Stefano Farina | last post by:
Hi all I have to develop an embedded database using memory FLASH and memory RAM Some tables must be saved in RAM and some tables in FLASH ( RAM and FLASH are two different mounted directories in...
3
by: TS | last post by:
I have 2 sql server databases on 2 different servers, a web app, and a crystal reports interface. When the app uses 1 database and the reports datasource points to a different database, both...
0
by: deepaks85 | last post by:
I need to create a CMS in which we will create user and each user should connected with the different airlines databases and that user will be able to upload files and view files in PDF and print...
3
by: scott.alfon | last post by:
Hello, i need your help. I want to implement using c/c++ where I can access to different database types as PostSQL, MySQL etc. The heterogenous databases are on different servers. Is that...
1
by: Dmitri | last post by:
Hi! I have a stored procedure that takes 22 minutes to run in one environment, that only takes 1 sec or so to run in another environment. Here is the exact situation: Database 1 on Server 1...
3
by: Aswanth | last post by:
Hi.., I'm having Two Stored Procedures in Two Different Databases.. Database1 - Employee Stored Procedure - Employee_Details Database2 - Company Stored Procedure - Company_Details
4
by: sganeshsvk | last post by:
sir, i want to store the same data values in two different databases at that same time in mysql using php programming. suppose any one databases data will lose then we use the other...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.