473,466 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Change

Hello,

I need to get a value which might be on a SQL database or Access
database.

My problem is I need to know which is the database type or, even
better, create a code which would work for both databases.

Anyway, first of all I am getting my connection string from Web.Config:

Dim connectionString As String =
ConfigurationManager.ConnectionStrings("Conn").Con nectionString

Then, if the database is SQL I have the code:

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

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

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

' Execute the command
connection.Open()
Dim content As SqlClient.SqlDataReader =
command.ExecuteReader
If content.Read Then
Return content.Item("Value").ToString()
Else
Return "# Undefined Value#"
End If
content.Close()
connection.Close()

If the database is Access there are a few changes just in types as
follows:

' Define connection
Dim connection As New
OleDb.OleDbConnection(Me.ConnectionString)

' Define command
Dim command As New OleDb.OleDbCommand
With command
.CommandText = "GetValue"
.Connection = connection
.CommandType = CommandType.StoredProcedure
End With

' Add command parameters
With command.Parameters
.Add(New OleDb.OleDbParameter("@ContentCulture", culture))
End With

' Execute the command
connection.Open()
Dim content As OleDb.OleDbDataReader = command.ExecuteReader
If content.Read Then
Return content.Item("Value").ToString()
Else
Return "# Undefined Value #"
End If
content.Close()
connection.Close()

How should I create this?

Thanks,

Miguel

Oct 23 '06 #1
0 871

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

Similar topics

4
by: J.C. Flores | last post by:
Hello all, First of all, I must state that I'm new to SQL Server, but have been a long-time software guy for quite some time. Please excuse the potential simplicity of the solution to my...
1
by: Spike | last post by:
Hello! Im going to make a javascript for changing alot of images. But im not sure how to do it., where to start.. Ok, first.. this is the isue. I have 3 images(I call them 1a-3a). when u...
0
by: beanweed | last post by:
BACKGROUND ---------- I have an ASP.NET application having two panels. In one panel, an XML document, transformed using xsl, is displayed. In the other panel are some controls that allow a user...
5
by: Hank | last post by:
My Access 2000 code has been running for several years in our main plant. Now we need to install it, as a stand-along application, at remote sites, some of which are out of state. My problem is...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
4
by: active | last post by:
It appears to me that if I change the Control's client size the controls size does not change to agree with the new size. Does it work like the VB6 ScaleWidth and ScaleHeight? That is after I...
3
by: Tom | last post by:
I am writing a Visual basic .Net database application. There are many forms that first let you select and look at a DB record and then when you click a "modify" button you are allowed to change...
2
by: J | last post by:
Hello. I apologize if this isn't the appropriate group for this question but I was wondering if it's possible to allow regular windows domain users to change their passwords through an .asp page? ...
11
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RowSource of a Master Report is: Me.RowSource = "TableOrQueryName"
1
by: monkey1001 | last post by:
my program is suppose to show my due change and i got it working but my change and coins are wrong how can i improve it thank you..(its supposed to be in java)
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.