Hi, I've created a simple hit counter in my Session_Start event... Dim myDataSource As New SqlDataSourcemyDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString1").ToStringmyDataSource.UpdateCommand = "UPDATE Stats SET Hits = Hits + 1"myDataSource.Update() It works fine but do I need to close the connection after I've finished with it or is this ok? Thanks for your help.
If this is used eg. Return selectCommand.ExecuteReader(CommandBehaviour.Default) Here do i need to close the connection in finally explicitly???? Are there any links which can answer this kind of question ??? Thanks for any help in advance.....
How do i close a current connection to a database using t-sql?I fail some time to drop the database getting messages that it'scurrently in use.Using the wizard to delete the database, i could check the option toclose all connections to the db, but how do i do it using t-sql?best regards
Then I Open the Connection. Now, in some ways I need to drop a Table. Before I do so, I disconnect the DB but I'm using only the line
cn.Close();
I saw om the Watch attributes that its not a real disconnect to the DB. When I try to Drop the Table I get this message: The system timed out waiting for a lock. [ Session id = 25,Thread id = -2096711882,Process id = -2090594918,Table name = Movies,Conflict type = x lock (s blocks),Resource = DDL ]
And the Table doesn't drop.
Is it related to the constructor line I made? What is the best solution to Drop a table..and then to get connected again with the DB.
How do you close the connection at the SQL Server? I have a backup I want to resotre to SQLExpress using SQL Management Studio Express. When I try, the SQL tells me he can't because the database is in use. I don't realy care about this I still want to restore the database. So I figured it's because there are some active connection to the database. My gues is I have to close those, but how? I also know I can restart SQLExpress and the connection will drop, but this server has more then one database, so I cant always do that. I'm looking for some T-SQL like DROP ALL CONNECTION. Thanks for the help.
I write a .NET Windows Form that connect to SQLExpress datafile. After updating data, I want to zip the .mdf file and send email. However, I got an exeption that the .mdf file is used by other thread so I cant zip. Even I try to close all connection, I still cant zip.
Is there any way to detach/unlock .mdf file connecting by SQLExpress?
hi, im totally new to this sql thing. i have a set of classes here and my objective is to show that they can connect to the database. how am i supposed to do this?
hello all the problem with me,im for the first time using SQL Server and ASP,so i have little knowledge baout these two progs.i want to know how pages in ASP are connected to databse. second, i installed SQL Server2005 along with asp from the same CD(option of instalation of both was available). There is also a way use SQL Server within the ASP Environment(addnew itmes>sqldatabase>). Question: if i create a databse through above method. then how i will use it in asp.net.Although i can do it by draging "SQL Data sourcr" from "Data" category in the "toolbox"however, i want to manually connect the application to Db.Something like this Page_load(0 { //db connection code goes here.//sqlcommand goes here. con.open() } i want some controls like txtboxes and label to manualy connect to databse tables. plz someone forward the code,
I designed a DTS package with eleven different connections. When I try to see the proberties of a connection the enterprise manager immediatly closes without giving me a warning. This happens only with two connections (in my example M1 and M2). This mistake has no influence to the execution of the package. In my opinion it is a fault of the DTS package desinger but may be that I made something wrong. Is there anybody who knows this mistake? Thanks for your help.
If CurrentProject.IsConnected Then MsgBox "Base ya Conectada.Procedemos a cerrarla primero", vbOKOnly If SQLConexion.State = adStateOpen Then SQLConexion.Close SQLConexion.Close End If SQLConexion.Open SQLSentencia AbreConexionSQLSERVER = 0
If I detect that the connection is opened while I am initializazing varriables, I want to close always the connection and then begins my aplicattion always opening the connection, but it always returns a error 91..
The following error message was displayed in the SQL server event log when the client application attempted to connect to sql server "The Tabular Data Stream (TDS) version 0x72020002 of the client library used to open the connection is unsupported or unknown. The connection has been closed. [CLIENT: XX.XX.XX.XX]"
I have the same problem like Ben. Trying to connect to database engine but failed all the time. I use a SQL 2005 Enterprise Eval version. When I connect to database engine, I put <my computer name>SQLEXPRESS, it gives me this message:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (.Net SqlClient Data Provider)
I checked the sqlbrowser and it's running. I also enabled port 1434 in Firewall. But it still doesn't work. However, when I connect to analysis service using just <my computer name>, it lets me connected. I tried many ways to fix this problem but still no luck. Could anyone help me solve this problem please? Thanks so much.
I'm looking for the query command that will go out to all the user Tables and will tell me what Indexes need to be reindexed.
We are having a problem with some of the tables and we don't know when our tables need to be reindexed other than when operations are stopped for our company.
Firstly I consider myself quite an experienced SQL Server user, andamnow using SQL Server 2005 Express for the main backend of mysoftware.My problem is thus: The boss needs to run reports; I have designedthese reports as SQL procedures, to be executed through an ASPapplication. Basic, and even medium sized (10,000+ records) reportingrun at an acceptable speed, but for anything larger, IIS timeouts andquery timeouts often cause problems.I subsequently came up with the idea that I could reduce processingtimes by up to two-thirds by writing information from eachcalculationstage to a number of tables as the reporting procedure runs..ie. stage 1, write to table xxx1,stage 2 reads table xxx1 and writes to table xxx2,stage 3 reads table xxx2 and writes to table xxx3,etc, etc, etcprocedure read final table, and outputs information.This works wonderfully, EXCEPT that two people can't run the samereport at the same time, because as one procedure creates and writesto table xxx2, the other procedure tries to drop the table, or read atable that has already been dropped....Does anyone have any suggestions about how to get around thisproblem?I have thought about generating the table names dynamically using'sp_execute', but the statement I need to run is far too long(apparently there is a maximum length you can pass to it), and evenbreaking it down into sub-procedures is soooooooooooooooo timeconsuming and inefficient having to format statements as strings(replacing quotes and so on)How can I use multiple tables, or indeed process HUGE procedures,withdynamic table names, or temporary tables?All answers/suggestions/questions gratefully received.Thanks
In SSIS package development environment, I was able to connect to an oracle database and pull data into my sql server database. I installed the client tools for oracle and I put an entry into the tnsnames.ora and I was able to connect.
But in production environment, if I deploy the package on sql server, I was wondering if I had to do the same job of downloading the oracle client tools onto my production machine --which creates a tnsnames.ora file to it default location and then edit it with tthe tns entry-- or is there a better way to do this--avoiding the download?
we have roughly 22 people connected to one database. But after a while, their applications begin to drag due to in and out communication with the server. When i check the active connections on the sql server, some times i see 157 active connections, please how to i set a timeout or connection interval close, so as reduce the heavy load being put on the server. Or how can i automatically close connections when they get higher than 50 connections.
Can you create a temporary table using an ad-hoc query?
What I am trying to do is a type of filter search (the user has this and this or this) were i will not know how may items the user is going to select until they submit....that is why i can't use a stored procedure(i think)....any help on how to do this?
I'm having trouble with a query and ASP. The query itself is easy. I need a temporary table to be filled with the contents of a select and then i need to select out of the temporary table and return the results to the ASP.
INSERT into @results (ItemID, ItemDescription, ItemType, ItemRequestedBy, ItemStatus, ItemQuantity, ItemCostPer, ItemOrderNumber, DateAdded, DateLastEdited) SELECT * from cr_EquipmentData
SELECT * from @results
When I run this in Query Analyser, I get exactly the results I need... But when I try and run the ASP script, I get an error about the recordset not being open. (It's not the ASP checking 'cos when I run a simple select statement it works)
I appreciate there is no use for the query as it stands, but eventually I want to be able to perform not destructive statements on the @results table before returning the data to ASP. This is more 'testing' than anything at the mo'
I am writing a stored procedure that outputs it's information to a temporary table while it assembles the information. Afterwards, it returns the contents of the temporary table as the results of the stored procedure.
I found that if you create the table, inside the SP, as an ordinary table, the information builds to that table considerably faster than if you use a true temporary table.
I found that if I create a user function that returns a table as it's return value, it is also as slow as if I used a true temporary table.
The database can amass over 2 million records in one table in just a few days. If I have the procedure query against this table, and output to an ordinary table it creates, and summarize the information it is adding to the table, then it takes an average of around 4 minutes to return the results from the query. If I change the output table to a temporary table (#temp), it between 12 and 15 minutes. Nothing else in the procedure changed. Just the kind of table. If I take the logic and move it to a function which returns those results in a RETURN table, it also takes over 14 minutes.
Why would it take so much longer outputing to a temporary table rather than a normal table? Is it because temporary tables are stored in a different database (tempdb)? Why would returning query results from a function be just as slow?
Hi, I am trying to join two tables usig two temporary tables.I want the Output as table2/table1 = Output
Select temp2.Value/temp1.Value as val from ( ( select count(*)as Value from [Master] m inner join [Spares]s on s.SId=m.SID where m.Valid_From between '2007-06-01' and '2007-06-30' )temp1 Union ( select isnull(sum(convert(numeric(10,0),s.Unit_Price)),'0') as Value from [Order] h inner join [Spares] s on s.Number = s.Number where h.Valid_Date between '2007-06-01' and '2007-06-30' ))temp2 as t
Our java application is running on oracle and now we would like to port it to sql server 2000. In oracle we have a global temporary tables that has an option on commit to delete rows. Now I am looking for the same option in sql server but as far as I can see sql server's local temporary tables are visible per connection. Since the connection are shared in the pool it seems I can not rely on local temporary tables since the connection does not get closed at the end of the user's session. I need something that is visible per transaction not per connection.
Is it a better approach just to create a regular table and basically have a trigger to delete all data on commit?
If a stored procedure invokes another stored procedure that creates atemporary table why can't the calling procedure see the temporary table?CREATE PROCEDURE dbo.GetTempASCREATE TABLE #Test([id] int not null identity,[name] as char(4))INSERT INTO #Test ([name]) VALUES ('Test')CREATE PROCEDURE dbo.TestASEXEC dbo.GetTempSELECT * FROM #Test -- Invalid object name '#Test'.Thanks,TP
Hi, just a quick question regarding performance and speed.Q. Run a complicated query three times or create a TEMPORARY table andaccess it as needed?I have a page where it will be accessed 10,000+ a day.In that page I have an SQL query where it involves 3 different tables(approximate table sizes T1) 200,000 T2) 900,000 T3) 20 records)I'll be running that query 3 times in that page...One to retrieve the content and display it on the page.Second to count the number of records (using COUNT(*) function)And third to retrieve the content regions. (using DISTINCT function)What would be the best way of doing...Running the SQL query 3 timesOrCreate a temporary table and access it as many time as I needRegards,
I would like to know from other members whether they are successful in using temporary tables within a stored procedure and use that stored procedure in a report.
My scenario is like this:
I have a stored procedure A which fetches the data from different tables based on the orderno passed as input parameter.
I have built another stored procedure B with a temporary table created and inserting the rows in to this temporary table based on vendor related specifc orders by calling the above procedure A.
I have used this stored procedure in the dataset created and getting this error:
Could not generate a list of fields for the query. Check the query syntax, or click the Refresh Fields on the query toolbar.
Does anybody encountered this and have a resolution.
The table definition for @temp is the same as TBL_EVENT_DEFINiTION. The problem is I need to add a field to the @temp table and define the values using an update statement. If I include the additional field in the @temp table declaration then I get an error saying something to the effect of the number of fields is different. Is there a way of altering the temporary table to add this field?
I'm creating a temporary table in a procedure to help me with some calculations. I would like the name of the temporary table to be 'dynamic', I mean, to have the hour it was created, something like this: create table #myTempTable15May11:10:00, so if someone access the procedure while it's running, he won't have problems in creating his 'own' temporary table (create table #myTempTable15May11:10:02). Is there anyway I can do this?
I tried to make a DTS to transform data in a text file, I used a Store Procedure that use a temp table (#Resultados) but the DTS give me an error.
I read that in this case I canīt use local temp tables but I can use global temp tables, then I changed in my Store, #Resultados by ##Resultados, bu the result was the same.
SELECT LEFT(RP.Grupo,3) + LEFT(RP.Equipo,12) + LEFT(RP.SubGrupo,2) + LEFT(D.Fecha,8) + D.Valor as Dato FROM ReportesPlantilla RP LEFT JOIN ##Resultados D ON RP.Planta = D.Planta AND RP.Etapa = D.Etapa AND RP.GrupoEquipo = D.GrupoEquipo AND RP.Equipo = D.Equipo AND RP.Concepto = D.Concepto AND D.Fecha BETWEEN @FechaIni AND @FechaFin