Showing posts with label building. Show all posts
Showing posts with label building. Show all posts

Friday, March 30, 2012

is it possible to put the raiseerror in a text file or show it to the user after its been

I am in process of building a website where the user can upload files and then those files are loaded in to a sql server database. I am using some sprocs to scrub the data and then insert them into the production database.. And in my sprpc before and after updating or inserting a record or scrubing... i am returning the count by raising an error. or returning the rownumber where the error occured.. is there any way i can get the raise error part or whatever error i get while scrubing the data and relay it back to the user in a user freindly way or in a text file... or the best thing is can i open smalll window where i can show them what processing is goin on and alert them if there are any errors...

Any help will be appreciated.

Regards

Karen

Take a look forSqlException.Errors. Any SqlError object has the number of error and another informations.

PS.: To another databases, take a look forOleDbException.Errors.

|||

Hi Karenros,

Based on my understanding, you want to use Raiserror to generate an error message and pass it to the client user. Client user may get an alerting message or write it to a text file when getting the error message. If I've misunderstood you ,please feel free to tell me, thanks.

You can put your sqlcommand in a try block and in your catch block, write sqlconnection.errors.message to a text file. Please remember do not assign the severity value of your error message more than 19, or else it maybe cause terminate your connection. Sample code is like the following:

 try { con.Open(); cmd.ExecuteNonQuery(); }catch (SqlException ex) {using(StreamWriter sw=new StreamWriter("your text log file path here")) {foreach (SqlError errin ex.Errors) sw.WriteLine(err.Message+"\n"); } }
Hope my suggestion helps
|||

Chen,

Thanks for your answer. yeah and thats exactly that i wanted to do... so that user would know if the import process was successful or not...

I have tried using sqlexception before with no luck.. may be i didnt import the right header files in order for that work and i have also seen on msdn that we need a sqlinfomessage class or something like to do it.. Pls correct me if i am wrong...

anyways i am gonna give it a try and will let you know...

Regards

Karen

|||

Below is an example of how you can use the InfoMessage event handler:

First you'll have to create an event handler for this event like below:

con.Open();
con.InfoMessage +=new SqlInfoMessageEventHandler(con_InfoMessage);// here i've registered for the event
... set up the command object
cmd.NotificationAutoEnlist =true;
cmd.ExecuteNonQuery();

Then you can go on and write any code you want in that event handler method.

private void con_InfoMessage(object sender, SqlInfoMessageEventArgs e)
{
// your file writing code goes here. The eventArgs e holds errors, messages, source etc.
// you can just use e.ToString() and everything is there for you.
}

Hope this will help.

|||

Hi Karenros,

I've tested the sqlexception code on my local machine and it does work fine. So, maybe you have made some mistakes somewhere else.

However, I think you can also trydhimant 's solution. That's really a good method to solve your problem. thanks

Monday, March 19, 2012

Is it possible to "disable" all restrictions on a Ms sql DB?

In meen. primary keys, NOT NULL, IDENTETIES...et.c

I have to do a maunally, one time, building of a database. Sometables has to
stay an some are to be exchanged. The foreignkey inforcemnt ill do for my
self so everything is correct. I just need to be allowed to de thede task
for a while. Is it impossible?

Regards
Anders"Flare" <dct_flare@.hotmail.com> wrote in message news:<3f302ad3$0$24659$edfadb0f@.dread14.news.tele.dk>...
> In meen. primary keys, NOT NULL, IDENTETIES...et.c
> I have to do a maunally, one time, building of a database. Sometables has to
> stay an some are to be exchanged. The foreignkey inforcemnt ill do for my
> self so everything is correct. I just need to be allowed to de thede task
> for a while. Is it impossible?
> Regards
> Anders

You can disable foreign keys, check constraints and triggers with
ALTER TABLE. But you can't disable primary keys, NULL/NOT NULL is
(usually) part of the column definition, and IDENTITY is a column
property, so they can't be enabled/disabled in the same way.

It's not entirely clear from your comments what problems you're having
with the import, so if you can be more specific then perhaps someone
can help.

Simon

Monday, March 12, 2012

Is it possible that Adomdclient being automatically downloaded and installed in the GAC on the C

In a winFX xaml brower project, a reference to Microsoft.AnalysisServices.AdomdClient.dll is added. After building, the project is published to the web server on the same machine. But when running the application on a client the following error occures:

Platform Requirements Not Met
Unable to install or run the application. The application requires that assembly Microsoft.AnalysisServices.AdomdClient Version 9.0.242.0 be installed in the Global Assembly Cache (GAC) first.

Is it required to install AdomdClient on the client machine? Is there any possibility that Adomdclient automatically downloaded on the client machine and installed in the Global Assembly Cache?

You should be able to build a simple script to downloand and automatically install "ADOMD.NET" package from http://www.microsoft.com/downloads/details.aspx?FamilyID=df0ba5aa-b4bd-4705-aa0a-b477ba72a9cb&DisplayLang=en

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

Is it possible that Adomdclient being automatically downloaded and installed in the GAC on t

In a winFX xaml brower project, a reference to Microsoft.AnalysisServices.AdomdClient.dll is added. After building, the project is published to the web server on the same machine. But when running the application on a client the following error occures:

Platform Requirements Not Met
Unable to install or run the application. The application requires that assembly Microsoft.AnalysisServices.AdomdClient Version 9.0.242.0 be installed in the Global Assembly Cache (GAC) first.

Is it required to install AdomdClient on the client machine? Is there any possibility that Adomdclient automatically downloaded on the client machine and installed in the Global Assembly Cache?

You should be able to build a simple script to downloand and automatically install "ADOMD.NET" package from http://www.microsoft.com/downloads/details.aspx?FamilyID=df0ba5aa-b4bd-4705-aa0a-b477ba72a9cb&DisplayLang=en

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.