in my package i'm using a for each loop container in order to process all files in a certain folder. everything works fine but of course when i start the service and there are no files available the package waits. is there a way to simply say skip the for each loop or semething like that?
it gives error while calling a sql stored procedure as "INPUT STRING WAS NOT IN A CORRECT FORMAT". I am providing the code here.public void get_issid(string cse_email, string tech_email, string subject, string issue_details, string response, string solv_date, out int issid) { // Establish ConnectionSqlConnection oConnection = GetConnection(); // build the commandSqlCommand oCommand = new SqlCommand("get_issid", oConnection); oCommand.CommandType = CommandType.StoredProcedure; // ParametersSqlParameter paracse_email = new SqlParameter("@cse_email", SqlDbType.VarChar, 50); paracse_email.Value =cse_email; oCommand.Parameters.Add(paracse_email); SqlParameter paratech_email = new SqlParameter("@tech_email", SqlDbType.VarChar,50); paratech_email.Value = cse_email; oCommand.Parameters.Add(paratech_email);SqlParameter parasubject = new SqlParameter("@subject", SqlDbType.VarChar, 50); parasubject.Value = subject; oCommand.Parameters.Add(parasubject);SqlParameter paraissue_details = new SqlParameter("@issue_details", SqlDbType.VarChar, 500); paraissue_details.Value = issue_details; oCommand.Parameters.Add(paraissue_details);SqlParameter pararesponse = new SqlParameter("@response", SqlDbType.VarChar, 500); pararesponse.Value = response; oCommand.Parameters.Add(pararesponse);SqlParameter parasolv_date = new SqlParameter("@solv_date", SqlDbType.DateTime); parasolv_date.Value = solv_date; oCommand.Parameters.Add(parasolv_date);SqlParameter paraissid = new SqlParameter("@issid", SqlDbType.Int);paraissid.Direction = ParameterDirection.Output; oCommand.Parameters.Add(paraissid); try { oConnection.Open(); oCommand.ExecuteNonQuery();issid = int.Parse(paraissid.Value.ToString()); }catch (Exception oException) {throw oException; } finally { oConnection.Close(); } }
the stored procedure is:
create proc [dbo].[get_issid](@tech_email varchar(50), @cse_email varchar(50),@subject varchar(50),@issue_details varchar(500),@response varchar(500),@solv_date datetime, @issid int output) as select @issid=tech_response.issue_id from tech_response,issue_details where tech_response.tech_email=@tech_email and tech_response.cse_email=@cse_email and tech_response.subject=@subject and tech_response.issue_details=@issue_details and response=@response and solv_date=@solv_date and tech_response.issue_id=issue_details.issue_id requested to help in this
I'm unsure how to handle an SQL Exception correctly when the database is unavailable/offline. I have my aspx file with the C# code-behind, but all of the SQL stuff is done in a separate code file in the App_Code directory.E.g. CODE-BEHINDDatabaseModifier.deleteUser(username); DATABASEMODIFIER.cspublic static void deleteUser(string username){ SqlConnection conn = SqlLogin.SqlConnect; SqlCommand command = new SqlCommand("DELETE FROM <table> WHERE Username = '" + username + "'", conn); conn.Open() command.ExecuteNonQuery(); conn.Close()} Now, that code works perfectly, however if the database I'm connecting to is offline, an SQLException is thrown and because the SQL is handled in my DatabaseModifier class, I'm not sure how to handle it correctly.If I use a Try/Catch block in my code-behind, it doesn't get thrown because the error occurs in my DatabaseModifier class. If I use a Try/Catch block in my DatabaseModifier class, what can I put in the catch block that will inform the user of the database being offline and/or how can I perform a url redirection? Any help is greatly appreciated.
Hi, Im Nithyananda working on a project with SQL server 6.0 Im having a stored procedure which inserts into a table . If I violate the primary key constraint on the table , I get a 2627 error. I would like to replace this error with my own.Could u tell me how to do it? Im an ORACLE guy and relatively new to SQL server. Is it possible for me to propogate the same error message to any front end? In my case ,Im using VC++ as front end. Could someone also tell me the way of calling a SQL stored procedure from VC++?
I m new to the sqlserver.In Oracle we can handle exceptions like this
declare name varchar(20); begin select ename into name from emp where eno=&eno; dbms_output.put_line(name); exception when no_data_found then dbms_output.put_line('No Entry'); end; /
We will get the message No Entry When corrsponding employee number dosent exists.
In Sqlserver how to handle these things.
Specifically my requirement is with select statement(Like above program)
Hello, I am trying to catch an error, but not able to. I am storing the value of @@Error soon after the statement which I believe would generate error. In order to produce the error I have deliberately used a wrong table name. So, the statement breaks but never comes to my error handling code snippet. Instead, it just throws the SQL server error message and quits. What am I doing wrong here? Here is the code snippet. The actual name of the temporary table is #TEMPO_TABLE, but in order to generate the error I have used #TEMPO_. Since this would surely error out, it should go to the label ROLLITBACK. But is not going to that label. Neither is it printing the error number as per the PRINT statement there. It just throws the SQL error and quits the execution. (Or should it NOT??). The Error that it throws it this:
Server: Msg 208, Level 16, State 1, Procedure FEED_PULL_XX, Line 157 Invalid object name '#TEMPO_'.
Can you please let me know whats going wrong here? Thanks a lot in advance.
SET @ErrNo = @@Error PRINT '@ErrNo is ' + ltrim(str(@ErrNo)) + '.' IF @ErrNo <> 0 Begin PRINT '@ErrNo is ' + ltrim(str(@ErrNo)) + '.' GOTO ROLLITBACK End
I am using exception handling and Transaction handling combined. The code is written to delete a record from 2 different table. The purpose of using exception and transaction handling combined is to make sure that the record is deleted in BOTH table. If there is error while deleting a record from one of the tables, it will rollback the database to the original and will stop deleting any record.
However, The Transaction handling is not working. When error occurs while deleting a record on table A, the code still delete a record from one table B. The transaction.RollBack() doesn't work. This is my code:
Try Conn = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString) Conn.Open() Trans = sConn.BeginTransaction
For Each row In GridView1.Rows Dim sql As String = "SELECT * FROM Member
Using Cmd As New SqlCommand(sql, Conn, Trans) SqlDataSource1.DeleteParameters("MemberID").DefaultValue = DropDownListMember.SelectedValue
SqlDataSource2.Delete() End Using End If Next sTrans.Commit() Label1.Text = "deleted." Catch ex As Exception If sTrans IsNot Nothing Then sTrans.Rollback() End If Label1.Text = "error" Return Finally If sConn IsNot Nothing Then sConn.Close() End If End Try
Hi guys, Does any one know how to detect when a SQL transaction has been rolled back in either a windows application or ASP.NET. My Transactions always run but when they are rolled back Visual Basic does not pick up any errors in the 'Try Catch SqlException'. Does any one know a way round this. Sorry for the lack of code. Im writing this post on a friends PC but i wil put up my code as soon as possible. Thanks in advance Matt
I'm trying to do exception handling in a stored procedure, such as IF (@@ERROR <> 0) execute and insert on to an error log table. I have set the volatile @@ERROR global to a variable, but the proc is still throwing a primary key exception; hence, it's not being trapped. My question is why isn't my exception being handled?
Here's my code, your help is much obliged. (my error proc is below the caller)
CREATE PROCEDURE [dbo].[INSERT_STATS_NO_GROUP_PROC] @stat_type_id int, @stat_delimited_file_id smallint, @time_interval datetime, @call_volume int, @Err int OUTPUT AS SET @Err = 0 DECLARE @Error int BEGIN TRANSACTION INSERT INTO DAILY_SUMMARY_STATISTICS ( stat_type_id, stat_delimited_file_id, ssda_customer_id, time_interval, call_volume ) VALUES ( @stat_type_id, @stat_delimited_file_id, NULL, @time_interval, @call_volume )
SET @Error = @@ERROR IF(@Error <> 0) BEGIN GOTO abort END COMMIT TRANSACTION
can I handle exception in SQL functions? how?? I am tring to migrate the Database from Oracle 9i to SQL server 2005 with SSMA which converts function in one procedure and wrapper function because of exception handling in Oracle.
I am trying to handle exceptions using try catch with remote database.
I am writing the following code which works fine if login locally but when I am trying to do the same on linked server its not being caught in try..catch block.
The procedure I am writing to raiserror
create proc CustomError as RAISERROR ('db error', 16, 1);
I am calling the above procedure in local database using following code
BEGIN TRY exec CustomError END TRY BEGIN CATCH select ERROR_MESSAGE() as ERROR_MESSAGE; END CATCH; GO
and it works perfectly. I am able to catch the error in catch block.
and i m getting the following result db error
but when i am trying to do the same on linked server the code doesn't take me to catch block. I am getting following error while executing the code
go BEGIN TRY exec [192.168.0.50].[BM].dbo.CustomError END TRY BEGIN CATCH select ERROR_MESSAGE(); END CATCH; GO
where [192.168.0.50] is a linked server name and BM is the database name and custom error is my sp which is on remote server.
its giving me following error
Msg 50000, Level 16, State 1, Procedure CustomError, Line 11 db error
I'm creating a class that will wrap a SqlException and will offer the developer a way of determining how to proceed in handling the exception by offering a suggestion of retrying, revalidating the data, and/or calling the entire process a no go.
One of the ways i've come up with to accomplish this is by using the severity (SqlException.Class) to assist in making a suggestion to the developer.
I'm hoping to get some feedback from the developers who use this forum if they feel severity is or is not the way to go, and also to offer any other ways of accomplishing that they can come up with.
Upon an exception being caught (i.e. when inserting a record, it violates integrity constraint), I would like to do my normal exception handling routine and then continue with the loop to the next record.
Is this possible? If so, how do I implement this behavior?
I'm trying to get to grips with the formview control and have a problem regarding where an exception is raised if SQL server raises an error when an insert is taking place. I am new to both asp.net & c# I have put the following code in the SqlDataSource2_Inserted & Formview1_Inserted events as a way of determining where the exception is raised: if (e.ExceptionHandled){ string exceptionmessage = e.Exception.Message; lblStatus.Text = exceptionmessage;} These two events are the only one's that have the ExceptionHandled and Exception properties. I run the code with data that will raise a duplicate key error from SQL Server but the error is not being caught by either of these two handlers. All I get is a page that starts with Server Error in '/SourceCode' Application.
Violation of UNIQUE KEY constraint 'IX_reftblAntigens'. Cannot insert duplicate key in object 'reftblAntigens'.The statement has been terminated. 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: Violation of UNIQUE KEY constraint 'IX_reftblAntigens'. Cannot insert duplicate key in object 'reftblAntigens'.The statement has been terminated.... Is there somewhere else I should be looking to handle this sort of thing? I thought using the databound controls would make life easier but I'm actually finding it more of a pain than coding everything myself.
Greetings everyone, I am attempting to build my first application using Microsofts Sql databases. It is a Windows Mobile application so I am using Sql Server Compact 3.5 with Visual Studio 2008 Beta 2. When I try and insert a new row into one of my tables, the app throws the error message shown in the title of this topic. '((System.Exception)($exception)).Message' threw an exception of type 'System.NotSupportedException'
My table has 4 columns (i have since changed my FavoriteAccount datatype from bit to Integer) http://i85.photobucket.com/albums/k71/Scionwest/table.jpg
Account type will either be "Checking" or "Savings" when a new row is added, the user will select what they want from a combo box.
Next is a snap shot of my startup form. http://i85.photobucket.com/albums/k71/Scionwest/form.jpg
Where it says "Favorite Account: None" in the top panel, I am using a link label. When a user clicks "None" it will go to a account creation wizard, and set the first account as it's primary/favorite. As more accounts are added the user can select which will be his/her primary/favorite. For now I am just creating a sample account when the label is clicked in an attempt to get something working. Below is the code used.
account.FavoriteAccount = 1;//datatype is an integer, I have changed it since I took the screenshot.
financesDataSet.BankAccount.Rows.Add(account); //The next three lines where added while I was trying to get this to work. //I don't know if I really need them or not, I receive the error regardless if these are here or not.
catch (global:ystem.InvalidCastException e) { //Stops at the following line, this error was caused by 'if (this.financesDataSet.BankAccount[num].FavoriteAccount == 1)'
throw new global:ystem.Data.StrongTypingException("The value for column 'FavoriteAccount' in table 'BankAccount' is DBNull.", e);
I have no idea what I am doing wrong, all of the code I used I retreived from Microsofts help documentation included with VS2008. I have tried used my TableAdapter.Insert() method and it still failed when it got to
if (this.financesDataSet.BankAccount[num].FavoriteAccount == 1)
in my refreshDatabase() method it still failed.
When I look, the data has been added into the database, it's just when I try to retreive it now, it bails on me. Am I retreiving the information wrong?
Hi, i have a package that uses a ForEach loop component to import flat files, and uses an OLE DB Destination component to insert the data into some staging tables (using table fast load with a max insert commit of 1000 rows), the biggest individual table import would be circa 5000 rows. At the end of each file import a stored proc is called to transfer the data into production tables, then the next file is imported.
Periodically (when importing more than 5 or 6 files) the process fails with the error message:
The transaction log for database 'blah' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases
This occurs when committing the data to staging. I do not start any transactions during this process, and the staging tables are cleaned out by truncating them, so i'm not sure exactly what is causing the log file to fill up (i'm not a DBA).
I know this is not specifically a SSIS problem, but can anyone give me a suggestion about the best way to handle the log file during an SSIS import? Should i execute a DBCC SHRINKFILE before each flat file is imported? Is there some other approach i should be taking to either insert the data or to move it from staging to production?
Hi,Currently we get data from more then 200 different sources and all ofour vendors provide data in different file formats. The problem is wehave more then 100 DTS packages now and the maintainance is verydiffucult.Every time our vendor changes the format we have to change in multipleDTS packages.Is anybody know what would be the right way of reducing the no. of DTSpackages.The type of file formats we get are .xls .txt .dat .csv etc. and .txt& .dat files comes with different delimitters. The # of columns alsovaries from file to file. Is it possible to have a DTS package whichcan handle diff file formats and loads data into a staging table andfrom there based of the source of the file we can move data intorespective tables & columns.We are using SQL SERVER 2000Thanks in advance.Subodh
Well, tha case here is simply that i have a (Suppliers.csv) as an Input. When taking that file, I do some validation on it's rows (Data type validations, Mandatory Fielda validations..etc). When some rows to do not meet the requirments i put in these validations , it is supposed to be directed to an (Errors) Table in my SQL DB.
I want to include the order of the invalid row in the input File (The row which did not pass from the pre-mentioned validations) within the (Errors) Table when i direct the invalid rows to it.
Hi,I'm developing a desktop C# app that uses SQL Everywhere as an embedded database. I generated strongly typed DataSet and use that to populate a DataGrid on my app.When the app first loads, it populates the DataGrid with a line like this:
however, this time, the following exception was thrown:
The database file cannot be found. Check the path to the database. [ File name = .\Inventories.sdf ]
Does anyone know what may be going on? I saw this article about a bug in VS 2005 when using strongly typed DataSets (http://channel9.msdn.com/wiki/default.aspx/MobileDeveloper.DatabaseCannotBeFoundErrorInTypedDataset) but that doesn't seem to apply here.
The connection string is identical both times that line of code is called so I'm a bit baffled with what's going on.
I have been encountering a problem using a CLR Assembly in SQL server. The Assembly is one provided by Microsoft for an example on using Exchange web services with SQL server.
Essentially what this package is, is a set of c# classes that access the Exchange 2007 Web Services via a set of user defined functions and views in MS SQL Server 2005.
We have not modified the code except to configure for our host environment.
We are able to register the assembly using the setup.sql file included. But when we try to access any of the views or use the functions we get the following error:
Msg 10314, Level 16, State 11, Line 10
An error occurred in the Microsoft .NET Framework while trying to load assembly id 65551. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:
System.IO.FileLoadException: Could not load file or assembly 'exchangeudfs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=777b97dde00f3dbe' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
We have 3 testing environments. 2 Windows 2003 servers called test and test2. Also a single Windows 2000 server called test3. Test and test2 have a full suite installed on them, web server, exchange 2007, sql server 2005, they are also domain controllers for their own domains.
We get the above error on test and test2 but it runs fine on test3. Test and test2 represent what our production environment is like. Test3 was just part of our troubleshooting process.
We have tried a lot to make this work. Here are some details on the things we have tried.
The database is set up to allow CLR Assemblies. This is part of the setup.sql.
The assembly's permission is set to external_access.
We have gone all the way to setting the file permissions on the dll to full control to the Everyone group.
We have tried different accounts to run the SQL Service. We've tried the system account, the local admin account and a seperate user account.
The database we are using is a fresh brand new database. Therefore it does not fit into the bug reported in this article: http://support.microsoft.com/kb/918040
I am really at a loss to where to go from here. Any ideas on why this 'out of the box' solution is causing us so many headaches would be appriciated.
After performing a join operation on two tables i get the below resultset
pid, fname, typename, pname, pcost
1, cad, bars, product-1, 100
2, har, witte, product-2, 120
3, nes, bars, product-3, 119
Now i need to create files with the obtained resultset like
Column 'fname' is the folder name and 'typename' should be the file in the particular folder.
For example the first record should be inserted into file name 'bars.txt' in the folder 'cad' and third record should be created in file name 'bars.txt' in the folder 'nes'.
I've just started looking at SSIS and have encountered what should hopefully be a simple problem to solve. I have a pipe-separated source file that looks like this (I've added Line numbers for simplicity):
In addition to a header and footer records, this file contains three record types for each person.
Record types are identified by the second column.
Each record type has a different number of columns:
Type 100 has 5 columns Type 200 has 4 columns Type 305 has 12 columns
The Row delimiter for all records is the {CR}{LF} character
I've set up a flat file input source and specified {CR}{LF} as the row delimiter for both header and data rows and the "|" character as the field delimiter.
It appears that SSIS is assuming that because the first data row has 5 columns, then everything must fit that format too. So the {CR}{LF} character that separates lines 02 and 03 is interpreted as text rather than a separation character and all remaining | field separators after 305 are interpreted as text containing in the fifth column. SSIS is also complaining that the last row is incomplete.
A bit like this (I've used tildes to indicate column separation):
I've seen one other reference to this behaviour but the response seemed to be SSIS doesn't know which columns are missing. In this scenario, we don't have missing columns, rather, we have different types of record in a single file. in DTS I would effectively parse the file once for each record type thus:
When running the package in VisualStudio it runs properly, but if I let this package run as part of an SQL-Server Agent job, I got the message "The script threw an exception: Exception of type 'System.OutOfMemoryException' was thrown." on my log and the package ends up with an error.
Both times it is exactly the same package on the same server, so I don't know how the debug or even if there is anything I need to debug?
We have created SSIS package to load a text file into a table. Source system shares 10 text files and recently they stopped generating data for one of the text file (comping empty), after few months they will start generating the data for the empty file batch processing.
The Issue here is Data Flow task is getting failed while loading empty text file into table. How to handle this empty file load issue in SSIS package.
i have restored site using stsadm, site get successfully restored. all user of the site able to access the site but the unable to access from same machine on which it is restored. i got the error The file exists. (Exception from HRESULT: 0x80070050)
I am executing script like this. How to check for the errors if "master..xp_cmdshell @bcpCommand" fails. Is there any way to verify that BCP is completed successfully
SET @FileName = 'E:TestBCPOut.txt' SET @bcpCommand = 'bcp "SELECT * FROM pubs1..authors ORDER BY au_lname" queryout "' SET @bcpCommand = @bcpCommand + @FileName + '" -c -U -P'
Guys, I need your help on this one. I have a problem here. There is an exception on my conn.Open. It said that "SQL Exception was unhandled by user code. Cannot open database requested in login 'MUSIC STORE'. Login fails.Login failed for user 'IT785P13student'." Does anyone have any idea what this means?
I downloaded a web site from internet and tried to open it in visual web developer express edition but it gave an error and the code and the error was: CODE- Return CType(Me.GetPropertyValue("Theme"),String) ERROR -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. An answer will be very good for me
Could somebody please tell me what is wrong with this SQL Statement. I'm trying to run it in SQL Server 2000, and keep getting the error: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'GROUP' but as far as I can see, there isn't anything wrong near "GROUP"..." SELECT b.ColorID, b.ColorName, " + " MAX(a.ColorID) AS DesignerProductAvailability_ColorID, " +" MAX(a.Quantity) AS DesignerProductAvailability_Quantity, " + " MAX(a.ProductID) AS DesignerProductAvailability_ProductID " +" FROM DesignerProductAvailability a " + " INNER JOIN ColorList b " +" ON b.ColorID = DesignerProductAvailability_ColorID " + " WHERE DesignerProductAvailability_ProductID = @ProductID AND " +" DesignerProductAvailability_Quantity > 0 " + " ORDER BY b.ColorName ASC " + " GROUP BY b.ColorName "; Any help would be greatly appreciated. Thanks in advance!