Foros del Web » Programación para mayores de 30 ;) » .NET »

leer cadena de conexion de un xml o txt externo

Estas en el tema de leer cadena de conexion de un xml o txt externo en el foro de .NET en Foros del Web. hola, tengo un programa que trabaja con bases de datos (sql 2005 express) y quisiera crear una ventana en donde el usuario configure su propia ...
  #1 (permalink)  
Antiguo 27/11/2008, 14:19
Avatar de robertgustavo  
Fecha de Ingreso: marzo-2008
Ubicación: Camaná - Arequipa
Mensajes: 213
Antigüedad: 16 años, 1 mes
Puntos: 4
leer cadena de conexion de un xml o txt externo

hola, tengo un programa que trabaja con bases de datos (sql 2005 express) y quisiera crear una ventana en donde el usuario configure su propia cadena de conexion, y no depender del app.config, como lograria esto? lo leeria de un xml externo?

!Ayuda !


miren en un proyecto que cree , no habia app.config , la aplicacion lo leia de un archivo, settings.settings


Option Strict On
Option Explicit On
Namespace My


<Global.System.Runtime.CompilerServices.CompilerGe neratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttrib ute("Microsoft.VisualStudio.Editors.SettingsDesign er.SettingsSingleFileGenerator", "8.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttrib ute(Global.System.ComponentModel.EditorBrowsableSt ate.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBas e

Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSetti ngsBase.Synchronized(New MySettings), MySettings)

#Region "Funcionalidad para autoguardar de My.Settings"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean

Private Shared addedHandlerLockObject As New Object

<Global.System.Diagnostics.DebuggerNonUserCodeAttr ibute(), Global.System.ComponentModel.EditorBrowsableAttrib ute(Global.System.ComponentModel.EditorBrowsableSt ate.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region

Public Shared ReadOnly Property [Default]() As MySettings
Get

#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
<Global.System.Configuration.ApplicationScopedSett ingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttri bute(), _
Global.System.Configuration.SpecialSettingAttribut e(Global.System.Configuration.SpecialSetting.Conne ctionString), _
Global.System.Configuration.DefaultSettingValueAtt ribute("Data Source=.\SQLEXPRESS;Initial Catalog=EMPPV2008;Integrated Security=True")> _
Public ReadOnly Property EMPPV2008ConnectionString() As String
Get
Return CType(Me("EMPPV2008ConnectionString"), String)
End Get

End Property
End Class
End Namespace

Namespace My

<Global.Microsoft.VisualBasic.HideModuleNameAttrib ute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttri bute(), _
Global.System.Runtime.CompilerServices.CompilerGen eratedAttribute()> _
Friend Module MySettingsProperty

<Global.System.ComponentModel.Design.HelpKeywordAt tribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.FacturaNow.My.MySettings
Get
Return Global.FacturaNow.My.MySettings.Default
End Get
End Property
End Module
End Namespace
__________________
Soluciones basadas en .NET Framework y SQL Server
  #2 (permalink)  
Antiguo 27/11/2008, 17:25
Avatar de Peterpay
Colaborador
 
Fecha de Ingreso: septiembre-2007
Ubicación: San Francisco, United States
Mensajes: 3.858
Antigüedad: 16 años, 7 meses
Puntos: 87
Respuesta: leer cadena de conexion de un xml o txt externo

q onda robert

te mando un link de algo que hice hace poco con la info para generar tus connectionstrings al vuelo pero usando el asistente de VS.

http://www.gurudotnet.com/index.php/...ra-aplicacion/

PD: Pero si guarda tu conexion en tu App.Config para que sea mas simple de usar, lo unico es q a tu usuario le facilites el usar el asistente en vez de escribir por su cuenta.
__________________
Curso WF4
http://cursos.gurudotnet.com/ DF
Aprende HTML5
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:19.