|
I have a asp.net web page. On this web page I have a OleDb Adaptor and Connection with a DataSet. I have bound a Datagrid yet when I run the page I receive this error...
Could not lock file.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Could not lock file.
Source Error:
Line 151: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Line 152: 'Put user code to initialize the page here
Line 153: OleDbDataAdapter1.Fill(DataSet11)
Line 154: DataGrid1.DataBind()
Line 155:
Does anyone have any ideas as to what I am doing wrong. I am new to working with Access and ADO so I know it must be something simple yet I am stumped.
Javolin
VB.Net, ASP.Net
|
|
|
|
|
Access makes a file to show that the DB has been locked - perhaps your DB is outside of the directory structure of your web app, and so the ASP.NET user does not have permission to create this file ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi
The problem is the following:
i have an ms access database containing a memo field and i want to insert a new record from within my c# app.
I use an ADO connection and an ADO command.
this is my sql command text:
"INSERT INTO ProductTable (Description) VALUES (' BLA BLA BLA BLA BLA')
All of this seemed to work fine, up until the moment i tried using longer strings.
When adding a string of more than 100 characters in the description field, the command executes normally (no errors), but when looking in the database afterwards shows me the value text is truncated to 100 characters. Editing the value in ms access works flawless, and (and this is the part i dont understand at all), when replacing my ado connection object and command by an ODBC connection object and command, it works just fine, it inserts the complete text without truncation!
Anybody have an idea where this comes from? Should i specify some "long string" property in my connection object? Are there other ways to do this using ADO, because i dont really want to use ODBC, as i read in different places that it is actually deprecated stuff.
thanks
|
|
|
|
|
i think it comes from the database restrictions instead...
what database do you use ?
isn't the field [ProductTable].[Description] set to varchar[100] or something like that ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
it is an access 2000 database, and the field type is "memo".
But even if this were the case, why does it work using the ODBC objects and not using the ADO ones?
|
|
|
|
|
Use parameterized queries and make the parameter data type adLongVarChar.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
Hi,
I am writing an application, which takes a access table < OLEDB 4.0 > provided by ADO.NET connection. I have used both OleDbDataReader as well as OleDbDataAdapter to fetch records from that table, but is providing me only 65536 rows where that table contatains 13000 rows. Neither I can export to it in a text file , nor I can show it to a DataGrid. Since I have to keep those records in some other Repository, please , some one , provide me such a solution to access all the rows..
[ if code placed , please Code it in C# ]
Thank you.
love2code
|
|
|
|
|
No body liked this questions.. How fool am I .. Shall I quit the programming ???
love2code
|
|
|
|
|
Hello,
I have a Receipts table with fields ID_receipt, WeekNumber, CustomerID. Then I have a Payments table with ID_payment, CustomerID, WeekShouldHaveBeenPaid, WeekPaid.
When I authorize a credit for a customer, I create all the payments on advance (say, 54) and starting the next week, I generate a receipt. Each week one payment will be marked as should-be-paid that week, but only when it really is paid the week number will be stored in the payment row.
I'm trying to migrate some old data to this new format. My problem is that I have the receipts, but I don't have the payments marked when they should be paid. Since I'll make this migration after a week is closed and before the next week is opened, getting those week numbers is easy: I just have to find the first receipt for a customer, mark the first payment with that week, and mark every payment with a consecutive week number until I run out of receipts.
I'm trying to think of a SQL query that could do this for me. Otherwise I'll have to write a little C# program that counts all the receipts and then marks each payment with the corresponding week number. But this is what SQL was made for, so there should be a way.....
Any ideas? Thanks!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
hi,
What does .net stand for? or What is the .net original name?
Thanks
|
|
|
|
|
|
i am working on a project to automatically generate view if the user select certain number of tables.
my problem is how can i save the query generated as a view
|
|
|
|
|
create an execute non query and create a view.
CREATE VIEW dbo.vw_myview
AS
SELECT * from mytable
|
|
|
|
|
i understand your anwser but my question is this
the query is autogenerated in a form of string in a text box
so how can i pass the string query and save it as a view
using sqldmo
|
|
|
|
|
Try something like this
You will have to fill in the blanks for connections string etc..
Before some pipes up with "injection attacks security risks etc..."
This is a very basic code to give an idea of how it could work.
=========================
string MySQL = TextBox1.Text; // SQL in the view select * from table
string MyViewName = TextBox2.Text; // The view name on DB
SQLstring = "CREATE VIEW " + MyViewName + " AS " + MySQL
SqlConnection myConnection = new SqlConnection(strConnectSQL);
SqlCommand myCommand = new SqlCommand( SQLstring, myConnection );
try
{
myConnection.Open();
myCommand.ExecuteScalar();
myConnection.Close();
}
catch
{
myConnection.Close();
}
|
|
|
|
|
I'm working with some people on other countries. I want all people will work
on the same database at certain server. Help me ASAP ! Thanks !
Hung
|
|
|
|
|
What version of SQL Server are you using ? I know this can be done, as I've connected to a SQL Server instance for a client in the USA, but I'm not sure how it's configured. I know SQL Server 2005 has a lot of new online functionality, but this was SS2000, I am certain.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I've connected directly to a SQL Server 2000 instance over the internet through a VPN connection. It was a bit slower than on the LAN, but that was only to be expected.
You can connect directly too, but even although my SQL Server is patched upto date I wouldn't want to expose it. My firewall log shows several blocked attempts at getting to SQL Server on my machine.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
I think There are several ways of doing this but of which i pretty much sure about is running your sql server instance on a server with Static IP. You also need to configure listener ports on the server.
The connection string will look something like this
This is Oledb provider
Provider=sqloledb;Data Source=10.20.50.100,1521;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd
if you are using Sql client on a Net framework skip the provider part and rest is same.
I hope this is helpful enough
Mandar Patankar
Microsoft Certified professional
|
|
|
|
|
Create hole in the firewall on a different port than standard SQL server and use NAT to move this each side of the firewall. Also filter the IP address range if possible (providing others have fixed IP addresses.)
|
|
|
|
|
I have a small problem with M.Access. I have a form which achieves data from the 'select' query. Beside, this form has the Default View of Continuous Forms and the the scroll-bar property of Vertical only. However, when I run the form, the form always shows the vertical scroll-bar despite of the number of records.
I ever saw another form having the same property with the above form. In contrast, this form only shows the vertical scroll-bar when necessary.
please show me the way to solve this problem. I'm in dark. Thanks a lot.
<vtalau>.
|
|
|
|
|
I am not an ADO expert -- but I have ADO code to fix...
I've got this process which talks to the SQL server a lot. But over time, we start to get errors on the connection. We basically open a single ADO connection and reuse it for all of our stored procedure needs.
My question is this -- is this an appropriate and efficient way to use it. To just open one connection and use it forever.
OR -- is it appropriate to open a connection each time we do a stored procedure?
Also, if the single connection approach is appropriate, how does one fix a messed up connection?
I am just looking for some practical guidelines toward using ADO.
(1) Should I use a single shared connection?
(2) Should I Open() a connection for each stored procedure transaction?
(3) What's the best way to correct a screwed connection?
Thanks in advance.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
I've never experienced this problem.
Normally, the recommended pattern is to create a connection for each operation or small group of related operations. With connection pooling enabled (the default), ADO will keep the physical connection open so it can be reused as required, creating additional connections only as they're needed. Connections that have been idle for a long time will eventually be disconnected.
Most connection objects are not thread-safe, IIRC. If there's a chance you're using your single connection object from multiple threads concurrently, this could well be causing your errors. Switching to a connection-per-operation model should sort this problem out.
In fact the ADO Connection object is marked as Apartment threaded. If you're using the correct operations to pass interface pointers between threads in a multithreaded program, calling a Connection object method will cause COM to marshal the call back to the thread that created the object. If you're not doing it properly, passing raw pointers around, then you could well be corrupting the internal state of the object.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks for the clarification. I am no ADO expert, and it seems we have no expert on staff. I changed the code to make a new connection for each operation, and it seems pretty happy.
Thanks.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
i'm going to have an 'after update' trigger. but in that trigger i want to know which row has been updated causing this triger. in that triger i want to update another row in other table by id of that updated row.
please help me.
Thanks
Rastegar
|
|
|
|