Truncate And Update Sql Database Web From In ASP.NET 2.0

Sep 30, 2007

I have two very simple stored procedures that truncate (clear out) the rows of my 'Transactions' table, then import rows from another table into it, thus updating the table with the appropriate data.

I would like to call these two stored procedures from a web form - asp.net 2.0 web page, using 2 buttons or possibly 1 button if I could, but can't find any information on how to do this.

here is code for:

1.  my button for 'truncate'

<asp:Button ID="Truncate" runat="server" Text="Truncate" style="left: 45px; position: relative; top: -2px" Font-Size="8pt" /><br />

2.  my stored procedure for 'truncate'

ALTER PROCEDURE dbo.TruncateTrans

AS

SET NOCOUNT ON;

Truncate Table Transactions;

 

2.  my button click event and page load event handler for the web form;

 

Imports System.Data

Imports System.Data.SqlClientPartial Class Admin_Default

Inherits System.Web.UI.PageProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End SubProtected Sub Truncate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Truncate.Click

End Sub

End Class

 

Also, here is my other stored procedure called updateTransact.  how can i execute these using the web form and buttons?  or is there another way to do this?

 

ALTER PROCEDURE [dbo].[UpdateTransAct]

AS

BEGIN

SET NOCOUNT ON;

SELECT *

FROM Transactions INNER JOIN

UpdateTrans ON Transactions.TransID = UpdateTrans.TransID

INSERT INTO Transactions (Account, TransID, TransType, Transkind, Status, Amount, Transdate, Note, Ticker, TickerType, BaseDate, BasePrice, UnitPrice, Shares, UnitsPerContract, Commission, StopTypes, FixedValue, Strategy, WithHolding, SavUnitPrice, SavCommis, ReInvestDividends, ReInvestCapGains, StrategyType, OrderID, ReferenceID, Fees)

SELECT Account, TransID, TransType, Transkind, Status, Amount, Transdate, Note, Ticker, TickerType, BaseDate, BasePrice, UnitPrice, Shares, UnitsPerContract, Commission, StopTypes, FixedValue, Strategy, WithHolding, SavUnitPrice, SavCommis, ReInvestDividends, ReInvestCapGains, StrategyType, OrderID, ReferenceID, Fees

FROM UpdateTrans

WHERE (TransType= 'C' OR TransType='O')

ORDER BY TransDate

END

 

Any help would be appreciated.

Craig

 

 

 

 

View 3 Replies


ADVERTISEMENT

Truncate Database Statement Help

Jul 23, 2005

Hello,I hope you can help me.We have a SQL Server 2000 database at work, (which works with a VB6frontend) which grew to a considerable size, so one of my past colleaguessent me this truncate statement to use on the database.I ran it like this, and all appeared to be well, it shrank the database,Shortly afterwards, after I ran this I noticed something not quite right.for example, one of the tables we keep is a User_Admin table which has 50records in there, when I accessed this using the frontend it only showed 1record, and this happened with every table in the database accessed by thefrontend.The data in the tables is still there, but only shows one record through thefrontend.Can anyone help me, and check this statement I ran, as its weird that allthis happened after I ran this statement.Thanks,Jayne Hegersp_dboption PBTDEV,'trunc. log on chkpt.', truecheckpoint--sp_dboption sadev,'trunc. log on chkpt.', falsesp_dboption PBTDEV,'autoshrink', true--sp_dboption sadev,'autoshrink', falseDBCC SHRINKDATABASE (PBTDEV, NOTRUNCATE)

View 2 Replies View Related

How To Truncate Complete Database?

Oct 26, 2006

Hello,

I want to truncate all tables present in the particular database, Is there any simple way to do it? or do I have to do it on individula basis (table by table)?



regards

View 4 Replies View Related

Job To Truncate Database Records More Than 15 Days Old

Jan 26, 2005

I have a SQL Server 2K db with some 10 tables and I want to setup a nightly job to truncate all db records which are more than 15 days old. Can anyone provide me with steps involved? Any help will be highly appreciated.

View 3 Replies View Related

Database Options/truncate Log On Checkpoint

Nov 27, 2000

I'm trying to make sure my database options are set up properly. Our database is used for our Decision Support System. The data is loaded in once a day. Should I have the truncate log on checkpoint on and should I limit the size that the log grows to. I just had to shrink the log. It grew so much that it took up all the space left. If I have the truncate log on checkpoint do I just have to issue the checkpoint command in order for it to truncate the transaction log?

View 1 Replies View Related

Truncate Transaction Log And SHRINK DATABASE

Aug 28, 2007

Is it possible to truncate Transaction Log and Shrink DATABASE while the database is being used by users or the database becomes unuvailable during this operations?

Thank you.

View 2 Replies View Related

Database Mirroring And Truncate Table Command

Jan 3, 2008



I was working on my Lab Environment and i had a DB which was mirrored in synchronous mode without witness server. I truncated one of the tables in this DB and did a failover to the mirror server. The table got truncated in the mirror too. Though we know that truncate is a non logged operation how does this mechanism work? Can someone please expain me??? Thanks in advance. Your replies will be very much helpful to me.

View 4 Replies View Related

'Truncate' Command Doesn't Truncate Enough

Dec 30, 2004

With a database size of almost 2 GB, I run the 'truncate table eventlog command' which completes successfully, but the database size only decreases by about 10 MB so stays too large - indeed the number of rows in the eventlog table is minimal, but the otehr tables in this database don't show such an amount of tables large enough to cause the size issue either. What could be the reason and how can I reduce it (possibly truncating another table but then which one, how could I determine which is too large and needs truncating?).

View 3 Replies View Related

Truncate Database Tables Based On Foreign Key Constraints

Nov 5, 2007

Guys,

I have 600 tables in my database, out of which 40 tables are look up value tables. I want generate truncate scripts which truncates all the tables in order of Parent child relationship excluding lookup tables. Is there any way to do this apart from figuring out Parent Child relationship and then writing the truncate statements for each of the table.

For example

EmployeeDetail table references Employee table
DepartmentDetail table references Department table
Department table references Employee table

My truncate script should be

TRUNCATE TABLE DEPARTMENTDETAIL
TRUNCATE TABLE EMPLOYEEDETAIL
TRUNCATE TABLE DEPARTMENT
TRUNCATE TABLE EMPLOYEE

Is there any automated way to figure out parent and child tables and generate truncate script for the same.

Thanks

View 1 Replies View Related

SQL Server Admin 2014 :: What Happens If Shrink Database With Truncate Only And Take A Backup

Apr 30, 2015

I would like to know what happens if i shrink the database with truncate only option and do a full backup or transaction log backup ? are the full backup or transaction log backup valid? I know that the performance of the database is bad if i shrink the database. What happens to full backup or transaction log backups?

View 9 Replies View Related

To Truncate Or Not To Truncate: That Is The Question..

Apr 17, 2008

Hi all...

Please forgive the elementary nature of my question, but could someone please explain the differences between these two database backup types:

1. Log backup
2. Log backup no truncate



From what I understand and have read, the "no truncate" backup method keeps the entire transaction log indefinitely. Using the truncation method, the transaction log is either 1) compressed or 2) cleaned up so that any completed transactions are removed from the log. Which one of these is true?


And, for the big question: is it better to run a backup of the transaction log with truncation or not? Our current backup scheme is similar to the following:


Full backup every 24 hours
transaction log backup every hour with no truncation


Should we insert a truncation backup somewhere in here? What is the danger of removing (or compressing) parts of the transaction log? Will this affect the restore process?


Thanks in advance!

View 6 Replies View Related

Help Send An Personal Email From Database Mail On Row Update-stored PROCEDURE Multi Update

May 27, 2008

hi need help how to send an email from database mail on row update
from stored PROCEDURE multi update
but i need to send a personal email evry employee get an email on row update
like send one after one email


i use FUNCTION i get on this forum to use split from multi update

how to loop for evry update send an single eamil to evry employee ID send one email

i update like this


Code Snippet
:

DECLARE @id nvarchar(1000)
set @id= '16703, 16704, 16757, 16924, 17041, 17077, 17084, 17103, 17129, 17134, 17186, 17190, 17203, 17205, 17289, 17294, 17295, 17296, 17309, 17316, 17317, 17322, 17325, 17337, 17338, 17339, 17348, 17349, 17350, 17357, 17360, 17361, 17362, 17366, 17367, 17370, 17372, 17373, 17374, 17377, 17380, 17382, 17383, 17385, 17386, 17391, 17392, 17393, 17394, 17395, 17396, 17397, 17398, 17400, 17401, 17402, 17407, 17408, 17409, 17410, 17411, 17412, 17413, 17414, 17415, 17417, 17418, 17419, 17420, 17422, 17423, 17424, 17425, 17426, 17427, 17428, 17430, 17431, 17432, 17442, 17443, 17444, 17447, 17448, 17449, 17450, 17451'
UPDATE s SET fld5 = 2
FROM Snha s
JOIN dbo.udf_SplitList(@id, ',') split
ON split.value = s.na
WHERE fld5 = 3

now
how to send an EMAIL for evry ROW update but "personal email" to the employee



Code Snippet
DECLARE @xml NVARCHAR(MAX)DECLARE @body NVARCHAR(MAX)
SET @xml =CAST(( SELECT
FirstName AS 'td','',
LastName AS 'td','' ,
SET @body = @body + @xml +'</table></body></html>'
EXEC msdb.dbo.sp_send_dbmail
@recipients =''
@copy_recipients='www@iec.com',
@body = @body,
@body_format ='HTML',
@subject ='test',
@profile_name ='bob'
END
ELSE
print 'no email today'


TNX

View 2 Replies View Related

UPDATE SQL Statement In Excel VBA Editor To Update Access Database - ADO - SQL

Jul 23, 2005

Hello,I am trying to update records in my database from excel data using vbaeditor within excel.In order to launch a query, I use SQL langage in ADO as follwing:------------------------------------------------------------Dim adoConn As ADODB.ConnectionDim adoRs As ADODB.RecordsetDim sConn As StringDim sSql As StringDim sOutput As StringsConn = "DSN=MS Access Database;" & _"DBQ=MyDatabasePath;" & _"DefaultDir=MyPathDirectory;" & _"DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;" &_"PWD=xxxxxx;UID=admin;"ID, A, B C.. are my table fieldssSql = "SELECT ID, `A`, B, `C being a date`, D, E, `F`, `H`, I, J,`K`, L" & _" FROM MyTblName" & _" WHERE (`A`='MyA')" & _" AND (`C`>{ts '" & Format(Date, "yyyy-mm-dd hh:mm:ss") & "'})"& _" ORDER BY `C` DESC"Set adoConn = New ADODB.ConnectionadoConn.Open sConnSet adoRs = New ADODB.RecordsetadoRs.Open Source:=sSql, _ActiveConnection:=adoConnadoRs.MoveFirstSheets("Sheet1").Range("a2").CopyFromRecordset adoRsSet adoRs = NothingSet adoConn = Nothing---------------------------------------------------------------Does Anyone know How I can use the UPDATE, DELETE INSERT SQL statementsin this environement? Copying SQL statements from access does not workas I would have to reference Access Object in my project which I do notwant if I can avoid. Ideally I would like to use only ADO system andSQL approach.Thank you very muchNono

View 1 Replies View Related

Cannot Truncate Table 'Database.dbo.Table' Because It Is Being Referenced By A FOREIGN KEY Constraint..

Aug 23, 2006

Here is my issue I am new to 2005 sql server, and am trying to take my old data which is exported to a txt file and import it to tables in sql. The older database is non relational, and I had made several exports for the way I want to build my tables. I built my packages fine and everything is working until I start building relationships. I remove my foreign key and the table with the primary key will get updated for the package again. I need to update the data daily into sql, and once in it will only be update from the package until the database is moved over.

It will run and update with a primary key until I add a foreign key to another database.

Here is my error when running the package when table 2 has a foreign key.

[Execute SQL Task] Error: Executing the query "TRUNCATE TABLE [consumer].[dbo].[Client] " failed with the following error: "Cannot truncate table 'consumer.dbo.Client' because it is being referenced by a FOREIGN KEY constraint.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

View 3 Replies View Related

Trigger To Update One Record On Update Of All The Tables Of Database

Jan 3, 2005

hi!

I have a big problem. If anyone can help.

I want to retrieve the last update time of database. Whenever any update or delete or insert happend to my database i want to store and retrieve that time.

I know one way is that i have to make a table that will store the datetime field and system trigger / trigger that can update this field record whenever any update insert or deletion occur in database.

But i don't know exactly how to do the coding for this?

Is there any other way to do this?

can DBCC help to retrieve this info?

Please advise me how to do this.

Thanks in advance.

Vaibhav

View 10 Replies View Related

T-SQL (SS2K8) :: Stored Procedure To Truncate And Insert Values In Table 1 And Update And Insert Values In Table 2

Apr 30, 2015

table2 is intially populated (basically this will serve as historical table for view); temptable and table2 will are similar except that table2 has two extra columns which are insertdt and updatedt

process:
1. get data from an existing view and insert in temptable
2. truncate/delete contents of table1
3. insert data in table1 by comparing temptable vs table2 (values that exists in temptable but not in table2 will be inserted)
4. insert data in table2 which are not yet present (comparing ID in t2 and temptable)
5. UPDATE table2 whose field/column VALUE is not equal with temptable. (meaning UNMATCHED VALUE)

* for #5 if a value from table2 (historical table) has changed compared to temptable (new result of view) this must be updated as well as the updateddt field value.

View 2 Replies View Related

Database Create ODBC Connections To Access Database Directly And Update Data?

Sep 10, 2012

We have a SQL database that uses Active Directory with Windows Authentication. Can users that are members of the Active Directory group that has read/write access to the SQL database create ODBC connections to access the database directly and update the data? They dont have individual logins on the server. They are only members of the Active Directory group that has a login?

View 1 Replies View Related

SQL Server 2008 :: How To Update The Database Physical File Location In Master Database

Mar 8, 2015

I had to to relocate the database log file and I issued an Alter database command but by mistake I put a space in the file name as below. The space is at the beginning file name. Now I am unable get the database loaded to SQL Server. The database has 2 replications configured, so deleting and re-attaching the database means the replication needs to be re-configured. Is there an alternative way to issue a command to update the database FILENAME ? Not sure if this can be edited in master database (sys files).

ALTER DATABASE [User_DB]
MODIFY FILE (NAME = User_DB_log, FILENAME = 'I:SQLLogs User_DB_log.ldf')
GO

View 1 Replies View Related

DB Design :: Buffer Database - Insert Information From Partners Then Make Update To Main Database

Oct 29, 2015

I actually work in an organisation and we have to find a solution about the data consistancy in the database. our partners use to send details to the organisation and inserted directly in the database, so we want to create a new database as a buffer database to insert informations from the partners then make an update to the main database. is there a better solution instead of that?

View 6 Replies View Related

Weekly Update Part Of Database With Data From Original Database

Mar 26, 2008

Hi!

I have an original database that I want to copy once to another database. Then I want to update the data weekly with the data of the original database. I don€™t change any tables or columns in that part of the database. Just some tables more in the €˜new€™ database (than the tables from the original database) with some references to the tables that have to be updated weekly.
How can I do this? (if you know what I mean... it's a sort of a datawarehouse where different sources come together.. that part that represents the original database is just a part of the datawarehouse. That part is exactly the same structure as the original database.)

Thanks,

Sandra

View 1 Replies View Related

How Can I Set A Update Trigger On A Table In Database A After A Record Had Been Updated From Another Database B?

Jan 22, 2008



Hi guys, may I know is it possible to create an update trigger like this ? Assuming there are two database, database A and database B and both are having same tables called 'Payments' table. I would like to update the Payments records on database A automatically after Payments records on database B had been updated. I can't use replication because both tables might having different records and some records are the same. Hope can get any assistance here, thank you.

Best Regards,
Hans

View 8 Replies View Related

Integration Services :: How To Insert / Update Table From Database 1 To Database 2

Oct 26, 2015

I am using two database server. Both are sql server. 

My task is :I want to insert data from server 1 table to server 2 table and update same when modified the existing data from server 1. is it possible to do the integration in single package.

I know to do insert and update seperately by ssis but need to do same with single task. 

View 5 Replies View Related

Failed To Update Database C:INETPUBWWWROOTAPP_DATAASPNETDB.MDF Because The Database Is Read-only.

Mar 4, 2006

I'm new to ASP.NET (I normally work with Windows Forms) and have installed the Club Website Starter Kit. I created an Administrators role and a user called "admin". When I run the project locally, everything works as it should - I can log in as admin and I can create new users.
I then copied the site to localhost (C:Inetpubwwwroot), but when I run the site from localhost, I can't log in (as admin or any other user); instead I get a message that says, "Your login attempt was not successful. Please try again."
Also, I can't create a new user. When I try, I get the following error:
Server Error in '/' Application.


Failed to update database "C:INETPUBWWWROOTAPP_DATAASPNETDB.MDF" because the database is read-only.
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.SqlClient.SqlException: Failed to update database "C:INETPUBWWWROOTAPP_DATAASPNETDB.MDF" because the database is read-only.Source Error:



An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:



[SqlException (0x80131904): Failed to update database "C:INETPUBWWWROOTAPP_DATAASPNETDB.MDF" because the database is read-only.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857242
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734854
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
System.Web.Security.SqlMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status) +3612
System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser() +305
System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e) +105
System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e) +453
System.Web.UI.WebControls.CreateUserWizard.OnBubbleEvent(Object source, EventArgs e) +149
System.Web.UI.WebControls.WizardChildTable.OnBubbleEvent(Object source, EventArgs args) +17
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102



Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
I figure there must be a simple(?) explanation and solution for this problem, and ideally, some sort of step-by-step procedure that new users to ASP.NET can follow to configure a site - such as one of the starter kits - to work correctly. I can honestly say that trying to get this working has been an extremely frustrating experience.
If someone could help me out, I would really appreciate it. I've been working on this for two days and feeling I have hit the wall.
Thanks in advance.
 

View 1 Replies View Related

Failed To Update Database C:INETPUB... Because The Database Is Read-only.

Mar 28, 2006

Hi there,I am getting a real problem with ASP.NET 2.0, all i am trying to do is run a recovert password (using the login controls) and i got the following error.Does anybody know how to fix this? I have tried the SSEUTIL answer here and it didn't work. http://forums.asp.net/909168/ShowPost.aspxI also ensured that Network Services user has READ/WRITE/EXECUTE premissions on the directory below and that each file isn't read only and also that it inherits ACL from the directory which it seems to do..Bit of strange one this, it isn't created (and i am not using) a beta version of VS 2005 Pro... but a full retail version.The PC is the local PC with IIS 5.1 and VS installed... it is the one i am using for developing.. I don't need to copy my files to the IIS directory below as that is where i have created it and open it in VS 2005 from there..I did read that if you use IIS 5.1 then the user should be ASPNET ... but i don't seem to have that use but a Network Services user...Any help or guidance would be really appreciated... i have come to a stop stage and can't get any further..Thanksian
Server Error in '/igdotcom' Application.


Failed to update database
"C:INETPUBWWWROOTIGDOTCOMAPP_DATAASPNETDB.MDF" because the database
is read-only. 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.SqlClient.SqlException: Failed to update database
"C:INETPUBWWWROOTIGDOTCOMAPP_DATAASPNETDB.MDF" because the database
is read-only.Source Error:



An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

View 3 Replies View Related

How To Update Data From This Database To Orther Database ?

Jun 20, 2007

 
Please help me How to update data from this Database to orther Database ?
Thank

View 5 Replies View Related

Failed To Update Database Because The Database Is Read-only

Mar 31, 2008

hi
i am currently testing my website on IIS7, and first error is that:
Server Error in '/' Application.


Failed to update database "C:INETPUBWWWROOTAPP_DATAASPNETDB.MDF" because the database is read-only.
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.SqlClient.SqlException: Failed to update database "C:INETPUBWWWROOTAPP_DATAASPNETDB.MDF" because the database is read-only.Source Error:



Line 109:
Line 110: conn.Open();
Line 111: SqlDataReader reader = command.ExecuteReader();
Line 112: reader.Close();
Line 113: command.Connection.Close();
i cheked on aspnet_Data folder to see if is read-only AND IT IS, but if i change it, the read-only property is setting up again. why?
thanks in advance

View 1 Replies View Related

Failed To Update Database Because The Database Is Read-only.

Dec 19, 2006

I am building a Windows Forms application in VS 2005, using C# and SQL Server 2005 Express as the backend.



When I try to accessd data from the db, it works with no problems.



When I try to insert/update/delete, I get the following error message



Failed to update database "DBNAME" because the database is read-only.



I am using a connection string with the following syntax:

"Data
Source=.SQLEXPRESS;AttachDbFilename=c:PATH_TO_DBdb.mdf;Database=MyDB;Integrated
Security=False;User Instance=False;User ID=USR;Password=PWD;"



I have made sure that the permissions on the DB are set (in Windows) so
that all users can modify. The user that is logging in to the DB has
status set to DBOWNER.



I have seen others experience the same problem - with ASP.net sites,
not Windows Forms sites (thus most of their solutions dont apply to me)



Any ideas on what is wrong and how I can get this to work?

View 9 Replies View Related

How Can I Update A SQL Database With An Access Database

Feb 14, 2008

I need to update an SQL database with an access database that is built on queries.  I need to do this nightly.
 
Can someone explain how to write the query for this and then I could add it to my nightly maintenance.
 
Thank you
Dee

View 10 Replies View Related

How Can I Update A SQL Database With An Access Database

Feb 14, 2008

I need to update an SQL database with an access database that is built on queries. I need to do this nightly.

Can someone explain how to write the query for this and then I could add it to my nightly maintenance.

Thank you
Dee

View 25 Replies View Related

How Can I Update A SQL Database With An Access Database

Feb 14, 2008


I need to update an SQL database with an access database that is built on queries. I need to do this nightly.

Can someone explain how to write the query for this and then I could add it to my nightly maintenance.

Thank you
Dee

View 9 Replies View Related

DataSet Rows Being Deleted, But After The Update , The Sql Database Is Not Updated. The Delete Rows Still In The Database.

Jun 4, 2007

 Stepping thru the code with the debugger shows the dataset rows being deleted.
 
After executing the code, and getting to the page presentation. Then I stop the debug and start the
page creation process again ( Page_Load ).    The database still has the original deleted dataset rows.
Adding rows works, then updating works fine, but deleting rows, does not seem to work.
 
The dataset is configured to send the DataSet updates to the database. Use the standard wizard to create the dataSet.
 
 
cDependChildTA.Fill(cDependChildDs._ClientDependentChild, UserId);        rowCountDb = cDependChildDs._ClientDependentChild.Count;               for (row = 0; row < rowCountDb; row++)        {           dr_dependentChild = cDependChildDs._ClientDependentChild.Rows[0];           dr_dependentChild.Delete();                      //cDependChildDs._ClientDependentChild.Rows.RemoveAt(0);           //cDependChildDs._ClientDependentChild.Rows.Remove(0);            /* update the Client Process Table Adapter*/          // cDependChildTA.Update(cDependChildDs._ClientDependentChild);      //     cDependChildTA.Update(cDependChildDs._ClientDependentChild);        }
        /* zero rows in the DataSet at this point */        /* update the Child  Table Adapter */       cDependChildTA.Update(cDependChildDs._ClientDependentChild);

View 1 Replies View Related

Cannot Truncate Due To Fks

Aug 1, 2007

i read that i can Truncate a table even if child table has no records so i tries to disable constraints but still can't get it to workCannot truncate table 'InventoryPC' because it is being referenced by a FOREIGN KEY constraint. disabling code on lines 9-13 and enabling codes on 36-40 1 ALTER PROCEDURE dbo.RevertDB
2
3 /* Reverts Database to original "Clean" State */
4 AS
5 SET NOCOUNT OFF
6 DECLARE @Log AS varchar(MAX), @RowsInDB AS int
7 SET @Log = 'RevertDB Started at ' + CAST(GETDATE() AS varchar(50)) + ''
8
9 /* *** Disable Constraints *** */
10 ALTER TABLE Booking NOCHECK CONSTRAINT ALL
11 ALTER TABLE InventoryPC NOCHECK CONSTRAINT ALL
12 ALTER TABLE PC NOCHECK CONSTRAINT ALL
13 ALTER TABLE Platform NOCHECK CONSTRAINT ALL
14
15 /* *** Start Truncates *** */
16 TRUNCATE TABLE Booking
17 SET @Log = @Log + 'Trucate Table Booking - Done' + ''
18 SET @RowsInDB = (SELECT COUNT(BookingID) FROM Booking)
19 SET @Log = @Log + '-- Rows Affected: ' + CAST(@@ROWCOUNT AS varchar(10)) + ', Rows in Table: ' + CAST(@RowsInDB AS varchar(10)) + ''
20
21 TRUNCATE TABLE InventoryPC
22 SET @Log = @Log + 'Trucate Table InventoryPC - Done' + ''
23 SET @RowsInDB = (SELECT COUNT(InventoryID) FROM InventoryPC)
24 SET @Log = @Log + '-- Rows Affected: ' + CAST(@@ROWCOUNT AS varchar(10)) + ', Rows in Table: ' + CAST(@RowsInDB AS varchar(10)) + ''
25
26 TRUNCATE TABLE PC
27 SET @Log = @Log + 'Trucate Table PC - Done' + ''
28 SET @RowsInDB = (SELECT COUNT(PCID) FROM PC)
29 SET @Log = @Log + '-- Rows Affected: ' + CAST(@@ROWCOUNT AS varchar(10)) + ', Rows in Table: ' + CAST(@RowsInDB AS varchar(10)) + ''
30
31 TRUNCATE TABLE Platform
32 SET @Log = @Log + 'Trucate Table Platform - Done' + ''
33 SET @RowsInDB = (SELECT COUNT(PlatformID) FROM Platform)
34 SET @Log = @Log + '-- Rows Affected: ' + CAST(@@ROWCOUNT AS varchar) + ', Rows in Table: ' + CAST(@RowsInDB AS varchar(10)) + ''
35
36 /* *** Enable Constraints *** */
37 ALTER TABLE Booking WITH CHECK CHECK CONSTRAINT ALL
38 ALTER TABLE InventoryPC WITH CHECK CHECK CONSTRAINT ALL
39 ALTER TABLE PC WITH CHECK CHECK CONSTRAINT ALL
40 ALTER TABLE Platform WITH CHECK CHECK CONSTRAINT ALL
41
42 SET @Log = @Log + '*** End Truncates ***' + ''
43 /* *** End Truncates *** */
44
45 /* *** Start Insert Platform *** */
46 SET @Log = @Log + 'Start Insert Platform' + ''
47
48 EXEC dbo.InsertPlatform 'Windows XP SP2 Professional Edition', 'Some description for Windows XP SP2 Professional Edition over here …'
49 EXEC dbo.InsertPlatform 'Windows Vista Ultimate', 'See everything you''re working on more clearly with Windows Aero, and quickly switch between windows or tasks using Windows Flip 3D and Live Thumbnails. You can easily find what you need—when you need it―with Instant Search and live icon previews that display the actual contents of your files. And while you''re at it, give your personal productivity a boost with instant access to the information you care about using Windows Sidebar and Gadgets. Put these easy-to-use and customizable mini-applications on your desktop and reveal the information you''re looking for at a glance.Website: http://www.microsoft.com/windows/products/windowsvista/seeit/default.mspx'
50 EXEC dbo.InsertPlatform 'Apple Mac OS X Tiger', 'Some description for Apple Mac OS X Tiger over here …'
51 EXEC dbo.InsertPlatform 'Apple Mac OS X Leopard', 'Desktop: The new look of Leopard showcases your favorite desktop image and puts new file Stacks at your fingertips for a stunning, clutter-free workspace.Finder: Browse your files like you browse your music with Cover Flow.Time Machine: See how your system looked on any given day and restore files with aWebsite: http://www.apple.com/macosx/leopard/features/'
52 EXEC dbo.InsertPlatform 'Red Hat Linux', 'Some description for Red Hat Linux over here …'
53
54 SET @Log = @Log + 'Rows In Platform: ' + (SELECT COUNT(PlatformID) FROM Platform) + ''
55 /* *** Start Insert PC *** */
56 SET @Log = @Log + 'Start Insert PC' + ''
57
58 DECLARE @WinXP int, @WinVista int, @OSXTiger int, @OSXLeopard int, @RedHat int
59 SET @WinXP = (SELECT PlatformID FROM Platform WHERE Title = 'Windows XP SP2 Professional Edition')
60 SET @WinVista = (SELECT PlatformID FROM Platform WHERE Title = 'Windows Vista Ultimate')
61 SET @OSXTiger = (SELECT PlatformID FROM Platform WHERE Title = 'Apple Mac OS X Tiger')
62 SET @OSXLeopard = (SELECT PlatformID FROM Platform WHERE Title = 'Apple Mac OS X Leopard')
63 SET @RedHat = (SELECT PlatformID FROM Platform WHERE Title = 'Red Hat Linux')
64
65 EXEC dbo.InsertPC 'Fusion PC One', 'Description here ...', 'Intel Core2 Duo E6600 2.4 GHz 1066MHz', '1GB Dual Channel DDR2 667 SDRAM', '120GB SATA2 NCQ HDD', 'NVIDIA GeForce 8600 256MB GDDR3', '22" 3000:1 Wide Screen LCD', @WinXP
66 EXEC dbo.InsertPC 'Fusion PC Two', 'Description here ...', 'Intel Core2 Duo E6850 3 GHz 1333MHz', '2GB Dual Channel DDR2 800 SDRAM', '240GB SATA2 NCQ HDD', 'NVIDIA GeForce 8800 Ultra 256MB GDDR3 SLI', '24" 3000:1 Wide Screen LCD', @WinVista
67 EXEC dbo.InsertPC 'Fusion PC Three', 'Description here ...', 'AMD Athlon 64 X2 Dual Core 6000+ 3 GHz', '2GB Dual Channel DDR2 667 SDRAM', '240GB SATA2 NCQ HDD', 'ATI Radeon Cross Fire 2900 256MB GDDR3', '24" 3000:1 Wide Screen LCD', @WinVista
68 EXEC dbo.InsertPC 'Fusion X1', 'Description here ...', 'Intel Core2 Extreme Q6850 3 GHz 1333MHz', '6GB Dual Channel DDR2 800 SDRAM', '500GB SATA2 NCQ HDD', 'NVIDIA GeForce 8800 Ultra 256MB GDDR3 SLI', '30" 3000:1 Wide Screen LCD', @OSXLeopard
69 EXEC dbo.InsertPC 'Fusion X2', 'Description here ...', 'AMD Athlon 64 FX 74 3 GHz', '6GB Dual Channel DDR2 800 SDRAM', '500GB SATA2 NCQ HDD', 'NVIDIA GeForce 8900 Ultra SLI 256MB GDDR3', '30" 3000:1 Wide Screen LCD', @WinVista
70 EXEC dbo.InsertPC 'Fusion Tiger 1', 'Description here ...', 'Intel Core2 Duo E6600 2.4 GHz 1066MHz', '2GB Dual Channel DDR2 800 SDRAM', '120GB SATA2 NCQ HDD', 'NVIDIA GeForce 8600 256MB GDDR3 SLI', '22" 3000:1 Wide Screen LCD', @OSXTiger
71 EXEC dbo.InsertPC 'Fusion Linux 1', 'Description here ...', 'AMD Athlon 64 X2 6000+ 3 GHz', '1GB Dual Channel DDR2 800 SDRAM', '120GB SATA2 NCQ HDD', 'NVIDIA GeForce 8600 256MB GDDR3', '22" 3000:1 Wide Screen LCD', @RedHat
72
73 SET @Log = @Log + 'Rows In PC: ' + (SELECT COUNT(PCID) FROM PC) + ''
74
75 /* *** Start Insert Inventory *** */
76 SET @Log = @Log + 'Start Insert Inventory' + ''
77
78 DECLARE @F1 int, @F2 int, @F3 int, @FX1 int, @FX2 int, @FT1 int, @FR1 int
79 SET @F1 = (SELECT PCID FROM PC WHERE Title = 'Fusion PC One')
80 SET @F2 = (SELECT PCID FROM PC WHERE Title = 'Fusion PC Two')
81 SET @F3 = (SELECT PCID FROM PC WHERE Title = 'Fusion PC Three')
82 SET @FX1 = (SELECT PCID FROM PC WHERE Title = 'Fusion X1')
83 SET @FX2 = (SELECT PCID FROM PC WHERE Title = 'Fusion X2')
84 SET @FT1 = (SELECT PCID FROM PC WHERE Title = 'Fusion Tiger One')
85 SET @FR1 = (SELECT PCID FROM PC WHERE Title = 'Fusion Linux One')
86
87 EXEC dbo.InsertInventory 10, @F1, 2.5, 'iCluster Fusion One'
88 EXEC dbo.InsertInventory 10, @F2, 2.5, 'iCluster Fusion Two'
89 EXEC dbo.InsertInventory 10, @F3, 2.5, 'iCluster Fusion Three'
90 EXEC dbo.InsertInventory 6, @FX1, 6, 'iCluster Fusion X1'
91 EXEC dbo.InsertInventory 6, @FX2, 6, 'iCluster Fusion X2'
92 EXEC dbo.InsertInventory 10, @FT1, 3, 'iCluster Fusion Tiger One'
93 EXEC dbo.InsertInventory 30, @FR1, 2, 'iCluster Fusion Linux One'
94
95 SET @Log = @Log + 'Rows In Inventory: ' + (SELECT COUNT(InventoryID) FROM InventoryPC) + ''
96
97 RETURN @Log
98
   

View 1 Replies View Related

Truncate Log

Nov 23, 1999

I would like to ask if I backuped the transaction log already, SQL will truncate the transaction log automatically or not. If not what should I do?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved