Friday, February 17, 2012

CreateDataAccessObjects

I tried the following code

Sub CreateDataAccessObjects(ByVal db As Database)

' Create relational datasource

Dim ds As New RelationalDataSource("THYROID", "THYROID")

ds.ConnectionString = "Provider=MSOLAP.3;Data Source=localhost;Initial Catalog=THYROID" MsgBox(db.ID)

db.DataSources.Add(ds)

' Create connection to datasource to extract schema to dataset

Dim dset As New DataSet()

Dim cn As New SqlConnection("Data Source=localhost;Initial Catalog=" & CbDatabase.Text)

' Create the customers data adapter with the

' calculated column appended

Dim daCustomers As New SqlDataAdapter("SELECT * FROM VISITS", cn)

daCustomers.FillSchema(dset, SchemaType.Mapped, "VISITS")

to create a relational datasource but I received the following exception

Login failed for user ''. The user is not associated with a trusted SQL Server connection.

On line of

Dim daCustomers As New SqlDataAdapter("SELECT * FROM VISITS", cn.

Any suggestions?

Thank you

You need to specify security information in your connection string, e.g.

Dim cn As New SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=" & CbDatabase.Text)

No comments:

Post a Comment