I have WPF accesses reporting service using report viewer object and received this error:
the underlying connection was closed. a connection that was expected to be kept alive was closed by server..
can anyone please help?
thanks
The problem is the datasource for the report. Since it is a local rdlc file that was copied from another solution, it no longer has the benefit of the datasource that was originally assigned to it. You must be setting the datasource manually to a datatable or to the result of a linq to sql query. To correct the problem, create a new datatable object, fill it with the results of your report query, and then assign it as the datasource for your report.
Related
I am new in vb.net programming. Am facing a problem in database handling. Am using oledb to deal with database, which is MS Access in my project. I am dealing with queries at the time. Now the problem is that my queries are working well on vb form but are not affecting the actual database. For example, when am adding a record, it displays 'record added successfully', the message I have used for my conformation, but the actual database is not displaying the record I just entered and even got the above conformation message as well. I have checked query in sql editor too, its doing well. I have checked locals in vb debug mode, all are containing correct values.
Am not getting what's the reason behind that. Why it is displaying the success message but not modifying the actual database. Same is the case when am firing delete query, till now. I have not tried Update query yet.
Technology - Visual Basic.net with MS Access
Am using Access 2007 and Visual Studio 2013
Please Help by your suggestions
Do the controls on your form have the correct control source, i.e. the database table/query from and to which it should be reading and writing to?
Basically the problem was the gap between my understanding and .Net's working.
Here is the solution.
You can include database in two ways:
1.Either importing it directly to your project from the place, for example using drag and drop, or some other such method.
2.Or, by including it via using wizard.
But, the difference lies in connection string you use in your project, if you give absolute path of database, then you will directly see the alterations in database you have done using your application, even in testing and debugging mode via IDE.
connection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\xyz.accdb"
But if you are using connection string provide by wizard, for example,
connection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\xyz.accdb"
what the IDE will be doing is whenever you will be running project for debugging or testing, every time, it will copy the actual database, with its contents as well, in /bin/Debug folder. So, the changes you are performing will only be visible to that copy, not the actual file. So, if you want to verify with the database, like in our case, check the copy of database, which will be present in /bin/Debug folder. You will see the changes there. But, every time you run project for debugging, it will replace that copy with original one.
So, actually I was checking the original database file, not that copy, since the changes were only made to that copy. So that is why I was facing the above problem, not due to any programming fault.
I'm using crystal reports 9, visual studio 2008, and oracle 9i in this project I'm doing. My crystal reports pull data from an oracle database, and are displayed on a CrystalReportViewer on a windows form. How would I make this connection using vb.net code?
Imagine this little scenario:
The host name for the oracle server is myHost.
The database name is myData
The username is myUser
The password is myPass.
Please assist me with the code to make this connection.
Your help will be highly appreciated.
Basically, you have a few options. If you've created a connection inside of the Crystal Report then you can hand off different login credentials to the report and crystal will handle it. You have to do it in a specific way through or it won't work (it's very picky on the order in which it's done). You will loop through the report and all the sub reports handing off new crendentials. The second route is to use a DataTable as your DataSource, populate it via VB.Net and hand it off (this doesn't sound like the route you're wanting to go).
Here are two blog entries where I describe how to pass new login credentials off to Crystal.
https://www.blakepell.com/2010-09-17-crystal-reports-changing-the-database-connection-from-net-subreport-links-and-the-case-of-the-missing-parameter-values
https://www.blakepell.com/2012-05-22-crystal-reports-extension-methods
In the first blog entry there is a "Private Sub ApplyNewServer(ByVal report As ReportDocument)" that will show you how to pass your new login and server information. It was extracted from another class so it might need slight modification to reference the login parameters you want to pass in.
Best of luck. ;)
Some background:
I'm trying to create a Server/Client Sync scenario for my application using Sync Services for ADO.NET specifically the LocalCache custom tool which sets the whole thing up for me.
My server DB has 5 Tables, all of which are being synchronized to the client application, which now has a SQL Server Compact DB with the same schema as the server DB. I have a dataset with some custom queries that I use to connect my app with the local database.
So far so good.
However in my application when I try to fill one of my tables with the table adapter on my form (the default "fill" method) it gives me the following exception:
No mapping exists from DbType Object to a known SqlDbType.
However, if I continue and do the fill again, IT WORKS without a problem.
Try
Me.WTSUsersTableAdapter.Fill(Me.WTSMainDataSet.WTSUsers)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
If I do the above code twice, one right after the other, the first one fails, the second works.
Another point to mention is that this happens only with this datatable, all the other 4 tables in the DB work as expected.
Does anyone have an idea what could be the cause of this?
Thanks a lot
Edit: I deleted my dataset and recreated it with no success. Anyone have an idea for me?
I found the answer to my question. There was a problem with a custom "UPDATE" query I had entered for the table adapter. For some reason, this prevented the table adapter from performing a simple "Fill", but only on the first try. It didn't seem to care about my Update error on the second try...
Go Figure.
What I did to find the problem was delete each custom query from the adapter and add them one at a time to see what was causing the error.
I am using Microsoft Visual Basic 2010 Express. I have a WPF-based project. I have a successful connection to a database in Database Explorer, and a working existing Data Source in Data Sources.
I created a datatable from the datasource using this code:
Dim roster_table As New DataTable("AGENT_ROSTER")
I can manipulate this datatable just fine, but I cannot figure out how to save its data to my database (agentroster.sdf) since the connection is on a global level, and isn't declared in this particular window.
How do I update this database from the datatable on this window?
By the way, I tried creating a connection on this window's code, using the exact same connection string as the successful globally-connected database, yet it said that it couldn't connect.
Tough to say given the limited information you provided. You should also note that there are a lot of ways to do this. However the most basic way is to use a table adapter. Once you've set the Update, Insert and Delete commands you call its Update method.
Here's an MSDN article that might help you further
In our server client software in vb6 with SQL2005, On server side one SQL table is continuously updated by data and we need to display data from this same table on client at running time. Pleases help how to access this same table from server and client so that data is continuously updated from server side and records in this table show on client software without error.
Your VB application needs to poll the table on occasion (as often as you need it to) to gather the new data, then display it as needed. Further assistance is going to require more information from you (such as, are you just asking us to write this for you?).
In VB6 you can use a timer control on the form to periodically check and reload the data to the form. If you are using an ADO recordset then reload the recordset with the table data and rebind to your form's values OR if you are using the built-in binding you will have to tell the form to reload and/or rebind. It's been a while since I have done VB6 so my memory on the exact steps is a little rusty.