Similar Threads:
1.adapter preview-data succeeds, but ASPX page says 'Cannot open database'
I'm trying to write an ASPX page that uses an OleDbDataAdapter to get
data from a SQL Server database. When I test the connection, it
returns success, and when I preview the data using the Adapter's
"preview data" right-click option, it works, but when I load the actual
page, I get the error "Cannot open database requested in login
'cookiecutter'. Login fails."
It seems to work when I use a pre-existing database like Northwind or
Portal, but not when I try creating a new one. But it looks like I'm
creating them correctly. Here are the exact steps:
1) In Visual Studio 2003 I go to Server Explorer, right-click "Data
Connections" and pick "Create new SQL Server database". I specify
BENNETTS_3_2002\NetSDK as the server name and "cookiecutter" as the new
database name. I select "Use Windows NT Integrated Security" as well.
2) The connection now appears, as expected, under Data Connections. If
I open its properties it shows BENNETTS_3_2002\NetSDK as the server
name, Use Windows NT Integrated Security is selected, and
"cookiecutter" is listed as the database to select. If I click "Test
Connection" it returns success.
3) In the ASP.Net project, I drop a new instance of an OleDbDataAdapter
onto a Web form, specify BENNETTS_3_2002\NetSDK.cookiecutter.dbo as the
data connection, and specify "SELECT wbuser.* FROM wbuser" as the
select command, the adapter gets created successfully. If I
right-click the adapter and click "Preview Data" I can see the contents
of the wbuser table being loaded.
4) BUT now if I put some code in the codebehind page like
DataSet objDataSet = new DataSet();
this.oleDbDataAdapter1.Fill(objDataSet);
when I actually try loading the page in the browser, I get the error
"Cannot open database requested in login 'cookiecutter'. Login fails."
Any idea what could cause this, if test-connection and preview-data
were reporting success? Could it have something to do with how I'm
creating the new database? Because if I go through the same steps
above but use a pre-existing database like Northwind or Portal, it
works. It only fails for the new databases I create. But I thought I
was creating them correctly, choosing "Use Windows NT Integrated
Security".
Help much appreciated, thanks!
-Bennett
2.Table Adapter - Preview Data - Null Args
How do you set a Stored Procedure's Parameter value to NULL in the
Preview Data Dialog of the Data Set Designers?
(Right Clicking on a TableAdpater configured for SPs will bring the
dialog up.)
3.How do I drop/auto configure my data adapters in my dos Middle-Tier project/app
Hi..
How do I drag&drop thus: auto configure with the wizard (or similar) the data adapters (i.e. mapped tables in my SQL Svr DB) that I need to be exposed in my non-windows Middle-Tier project/app
Yes, it easy to do this in a windows app. But how does it get done in a non-windows app. Currently I am having to code it by hand which is rather time consuming etc
In most code examples I have seen, SP's are used for the middle-tier, unfortunetly the requirements in my app do not allow (or it is not suggested) for SP's. Thus i need the functionality and ease-of use of multiple, dedicated and mapped data adapters in the Mid-Tier
Is there an easy way to do this. I was once told it is possible, but there is a trick to it
Please.... Wot is that Trick???
4.Data Adapters, Data Sets, Data TableMappings, and XML
Here's what I'm trying to do:
1. Create a data adapter with Select and Insert commands.
2. Use DataTableMappings to map XML tags into columns in a
data base table.
3. Create a dataset
3. Read in a schema using dataset.ReadXmLSchema
4. Read in an xml file that contains the data using
dataset.Read XML
5. Add 3 new columns to the dataset. (These columns have
already been mapped in step 2).
6. Put data in the 3 new columns.
7. Modify some data in the other columns using xpath
queries to find the nodes that need changing.
8. Use datadapter.update(dataset, tablename)
Everything seems to work fine until step 8. I get all the
data, the extra columns get added, and the data in other
columns gets modified. When I execute step 8 I get:
Run-time exception thrown :
System.InvalidOperationException - Cannot add or remove
columns from the table once the DataSet is mapped to a
loaded XML document.
Any ideas about how I can either fix this or do it another
way.
TIA,
Candi
5.problem with data adapter and data set while inserting and retrieving data
i am using a data adapter and a dataset for filling and retrieving data
into .mdb database.
following is the code.....
for the form load event
Dim dc(0) As DataColumn
Try
If OleDbConnection1.State = ConnectionState.Closed Then
OleDbConnection1.Open()
Else
MsgBox("connection can not be established")
End If
DA.Fill(DataSet11, "Table1")
cmd = New OleDbCommandBuilder(DA)
dc(0) = DataSet11.Tables("Table1").Columns("EmpID")
DataSet11.Tables("Table1").PrimaryKey = dc
Catch ex As Exception
MsgBox(ex.Message)
End Try
Delete.Enabled = False
End Sub
for inserting values into the DB
Private Sub Insert_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Insert.Click
Dim dr As DataRow
dr = DataSet11.Tables("Table1").NewRow
dr.Item(0) = Val(TB1.Text)
dr.Item(1) = TB2.Text
dr.Item(2) = TB3.Text
dr.Item(3) = Val(TB4.Text)
dr.Item(4) = TB5.Text
DataSet11.Tables("Table1").Rows.Add(dr)
DA.Update(DataSet11, "Table1")
MsgBox("data is saved")
rno = 0
call filldata()
filldata function consists of the following
With DataSet11.Tables("Table1").Rows(rno)
TB1.Text = Trim(.Item(0))
TB2.Text = Trim(.Item(1))
TB3.Text = Trim(.Item(2))
TB5.Text = Trim(.Item(4))
End With
the error it gives is " there is no row at
0........system.nullreference...........i checked the connection and
its working fine and also the database is getting accessed........the
error is occuring at the line " With
DataSet11.Tables("Table1").Rows(rno) "
6. datagrid not displaying data table data
7. Data->Generate Dataset|Preview Data