SoftJaƩn replied to Samuel-SMH
20-Nov-09 09:35 AM
Hola, Samuel:

Si tu intenci?n es a?adir una cadena de conexi?n al archivo de configuraci?n
de la aplicaci?n (App.config), lo que tienes que hacer es crear una
propiedad que guarde los par?metros necesarios para establecer la conexi?n
con tu base de datos.

Para ello, abre las propiedades del proyecto (Proyecto --> Propiedades de
NombreProyecto...). Selecciona la pesta?a Configuraci?n, y en la cuadr?cula
de la derecha, escribe los distintos valores:

Nombre = cadenaConexion
Tipo = (Cadena de conexi?n)
?mbito = Aplicaci?n
Valor = Data Source=(local);Initial Catalog=Nombre_Base_Datos;Integrated
Security=SSPI

El valor es para establecer una conexi?n con una base de datos Microsoft SQL
Server. Si usas otro tipo de base de datos, tendr?s que especificar los
par?metros adecuados a dicho sistema de gesti?n de base de datos.

De ?sta manera, Visual Studio crear? por t? el archivo de configuraci?n de
la aplicaci?n, el cual podr?s visualizarlo haciendo doble clic sobre el
archivo ?app.config? existente en la ventana Explorador de soluciones.

Ahora, vamos a utilizar dicha propiedad para obtener los datos de la tabla
Clientes, los cuales mostraremos en un control DataGridView:

' Obtenemos el valor de la propiedad llamada ?cadenaConexion?.
'
Dim connString As String = My.Settings.cadenaConexion

' Establecemos la cadena de conexi?n
'
Using cnn As New SqlConnection(connString)

Dim sql As String = "SELECT * FROM Clientes"

Dim da As New SqlDataAdapter(sql, cnn)

Dim dt As New DataTable("Clientes")

da.Fill(dt)

datagridview1.datasource = dt

End Using

End Sub

Como podr?s observar, no hay mucho misterio. :-)

Un saludo

--
Enrique Mart?nez
[MS MVP - VB]

Nota informativa: La informaci?n contenida en este mensaje, as? como el
c?digo fuente incluido en el mismo, se proporciona ?COMO EST??, sin
garant?as de ninguna clase, y no otorga derecho alguno. Usted asume
cualquier riesgo al poner en pr?ctica, utilizar o ejecutar lo recomendado o
sugerido en el presente mensaje.
Data
(1)
Source
(1)
Security
(1)
SQL
(1)
Server
(1)
Visual
(1)
Settings
(1)
SqlConnection
(1)
help
Hi there: I'm trying to open a SQL Server 2005 Database without creating a Data Source, but I receive a login error message. My code looks like: SqlConnection conn = new SqlConnection(@"Data Source = . \ SQLExpress;Integrated Security = true;Initial Catalog = MyDatabase.mdf;User Instance = true"); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM MyDatabase ASP.NET app, add the database to App_Data folder, and use the following connection string: "Data Source = . \ SQLEXPRESS;AttachDbFilename = | DataDirectory | \ MyDatabase.mdf;Integrated Security = True;User Instance = True", it opens fine, but I understand that in this case, the
Express DB. I have 2 Clients using it fine. It accesses stored procs to update data. The clients use integrated security. data source = 'SQLSERVER \ SQLEXPRESS';initial catalog = tbrPData;integrated security = SSPI The problem is on the third client I get Exsecute perimission denied on sp message. It also uses integrated security. How do I find out what user this client is accessing the DB with??? rotsey Database (1) Install (1) RebeccaC (1) TbrPData (1) Exsecute (1) If you are using integrated security, the user that is used to access the database is the same one that is will have a profiler that shows you the actions in the DB, What kind of security you have in your DB? well it must be a windows group because the other
String to Dictionary .NET Framework " / > Hello, I have the following string: String conn = " Provider = System.Data.SqlClient; Metadata = c: \ metadata | c: \ Metadata \ Sql; Provider Connection String = 'Data Source = localhost; Initial Catalog = AdventureWorks;Integrated Security = True;Connection Timeout = 60' This string contains pairs of Keys / Values. For example: Provider = System Data.SqlClient; Becomes Key = "Provider", Value = "System.Data.SqlClient". If a Value contains '' I want to remove those. For example: 2) Provider Connection String = 'Data Source = localhost; Initial Catalog = AdventureWorks;Integrated Security = True;Connection Timeout = 60' Becomes Key = "Provider Connection String
trouble refreshing a datagrid control bound to a dataset that was created from the New Data Source wizard. What is the code required to refresh the datagrid with data from the data source (sql db)? More Details: The application is C# Windows (VS 2005). I used the "Add New Data Source" wizard to connect to a sql database and select the tables to include in the in-memory dataset. From the Data Source window, I selected a table, designated it as a datagrid and then dragged it
Inserting, updating, etc. for ListView with a custom data source .NET Framework In ASP.NET 3.5: Suppose I have a ListView whose data source (using LINQ-to-SQL) is set with an expression for a DataSource instead of a bid.ParticipantId = Session["userParticipantId"]; bid.BidPrice = bidPrice; bid.BidDateTime = DateTime.Now; bid.IsOnlineBid = true; AuctionData data = new AuctionData(); data.Bids.InsertOnSubmit(bid); data.SubmitChanges(); But I do not know what my source should be for the itemId with which this Bid should be associated. it is the