Click here to Skip to main content
15,908,775 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: ASP.NET 2.0 secure source code Pin
Guffa23-Oct-06 13:41
Guffa23-Oct-06 13:41 
GeneralRe: ASP.NET 2.0 secure source code Pin
kaliem23-Oct-06 14:10
kaliem23-Oct-06 14:10 
QuestionDatagrid add column Pin
eagertolearn23-Oct-06 6:46
eagertolearn23-Oct-06 6:46 
AnswerRe: Datagrid add column Pin
Mike Ellison23-Oct-06 8:51
Mike Ellison23-Oct-06 8:51 
GeneralRe: Datagrid add column Pin
eagertolearn23-Oct-06 12:17
eagertolearn23-Oct-06 12:17 
GeneralRe: Datagrid add column Pin
Mike Ellison23-Oct-06 12:49
Mike Ellison23-Oct-06 12:49 
QuestionMTOM WSE 3.0 problem Pin
sunsmile23-Oct-06 6:11
sunsmile23-Oct-06 6:11 
QuestionUse different databases Pin
shapper23-Oct-06 5:10
shapper23-Oct-06 5:10 
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").ConnectionString

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
AnswerRe: Use different databases Pin
ednrgc23-Oct-06 6:28
ednrgc23-Oct-06 6:28 
QuestionHow to develop a user control? Pin
Old Gun23-Oct-06 1:32
Old Gun23-Oct-06 1:32 
AnswerRe: How to develop a user control? Pin
ednrgc23-Oct-06 4:21
ednrgc23-Oct-06 4:21 
GeneralRe: How to develop a user control? Pin
Old Gun24-Oct-06 3:30
Old Gun24-Oct-06 3:30 
GeneralRe: How to develop a user control? Pin
Old Gun26-Oct-06 3:22
Old Gun26-Oct-06 3:22 
GeneralRe: How to develop a user control? Pin
Old Gun26-Oct-06 3:23
Old Gun26-Oct-06 3:23 
QuestionDropDownList Databinding Question Pin
Dayekh23-Oct-06 1:24
Dayekh23-Oct-06 1:24 
AnswerRe: DropDownList Databinding Question Pin
Paddy Boyd23-Oct-06 3:30
Paddy Boyd23-Oct-06 3:30 
GeneralRe: DropDownList Databinding Question Pin
Dayekh23-Oct-06 3:57
Dayekh23-Oct-06 3:57 
GeneralRe: DropDownList Databinding Question Pin
Paddy Boyd23-Oct-06 4:14
Paddy Boyd23-Oct-06 4:14 
GeneralRe: DropDownList Databinding Question Pin
Dayekh23-Oct-06 5:01
Dayekh23-Oct-06 5:01 
GeneralRe: DropDownList Databinding Question Pin
Paddy Boyd23-Oct-06 5:02
Paddy Boyd23-Oct-06 5:02 
QuestionRegarding flash intro Pin
rajesh22523-Oct-06 1:10
rajesh22523-Oct-06 1:10 
AnswerRe: Regarding flash intro Pin
ednrgc23-Oct-06 2:44
ednrgc23-Oct-06 2:44 
AnswerRe: Regarding flash intro Pin
Britney S. Morales23-Oct-06 3:52
Britney S. Morales23-Oct-06 3:52 
GeneralRe: Regarding flash intro Pin
ednrgc23-Oct-06 6:34
ednrgc23-Oct-06 6:34 
Questiondrag and drop the items between 2 listboxes Pin
gane838323-Oct-06 0:05
gane838323-Oct-06 0:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.