Showing posts with label pretty. Show all posts
Showing posts with label pretty. Show all posts

Thursday, March 8, 2012

Check before INSERT

I have a pretty standard form that inserts users name, office, and team. It generates a random 10 digit ID for them. How would i got about checking the table to make sure that ID doesn't exist?

Here's my insert code.

string strConnection = ConfigurationManager.ConnectionStrings["TimeAccountingConnectionString"].ConnectionString;
SqlConnection myConnection = new SqlConnection(strConnection);

string usercode = GenPassWithCap(9);

String insertCmd = "INSERT into users (ID, firstname, lastname, office, team) values (@.id, @.firstname, @.lastname, @.office, @.team)";
SqlCommand myCommand = new SqlCommand(insertCmd, myConnection);

myCommand.Parameters.Add(new SqlParameter("@.id", SqlDbType.VarChar, 10));
myCommand.Parameters["@.id"].Value = usercode;

myCommand.Parameters.Add(new SqlParameter("@.firstname", SqlDbType.VarChar, 50));
myCommand.Parameters["@.firstname"].Value = txtFirstName.Text;

myCommand.Parameters.Add(new SqlParameter("@.lastname", SqlDbType.VarChar, 50));
myCommand.Parameters["@.lastname"].Value = txtLastName.Text;

myCommand.Parameters.Add(new SqlParameter("@.office", SqlDbType.VarChar, 75));
myCommand.Parameters["@.office"].Value = dwnOffice.SelectedValue;

myCommand.Parameters.Add(new SqlParameter("@.team", SqlDbType.VarChar, 20));
myCommand.Parameters["@.team"].Value = dwnTeam.SelectedValue;

myCommand.Connection.Open();

myCommand.ExecuteNonQuery();

Do I run a completey different select command before hand and try to match that field?

Instead of an adhoc T-SQL like this, you could pass the parameters to a proc and do a check before inserting.

IF NOT EXISTS(SELECT * FROM TableWHERE Id = @.ID AND Lastname = @.LastName And...)

INSERT INTO Users (...)

Wednesday, March 7, 2012

Charts not rendering

Hi, this is a pretty vague post but hopefully someone will be able to help.
I've recently experienced some problems where the charts wouldn't render at
all and the standard IE broken image X would display. Refreshing the page
doesn't help and neither does reopening the report. I have a feeling that
it might be IIS or the server itself...has anyone else experienced this and,
if applicable, what did you do to solve it?Did you look at this posting?
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=26004e9b-814f-465d-9c62-98813d8d7a3c&sloc=en-us
Also, does the hostname contain certain characters (like underscores?) -
then you might run into:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;275033
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Casey Rosing" <casey@.climark.com> wrote in message
news:eVUdCSnpEHA.132@.TK2MSFTNGP14.phx.gbl...
> Hi, this is a pretty vague post but hopefully someone will be able to
help.
> I've recently experienced some problems where the charts wouldn't render
at
> all and the standard IE broken image X would display. Refreshing the page
> doesn't help and neither does reopening the report. I have a feeling that
> it might be IIS or the server itself...has anyone else experienced this
and,
> if applicable, what did you do to solve it?
>

Saturday, February 25, 2012

Chart Types

Hi,

I have seen on the internet that there are more chart types availlable then used by reporting services.

I have seen some pretty charts in exel 2007.

Are there possibilities to use such charts in RS.

I have also seen that you can purchase charts from special dev houses (like dundas).

So i think i must be able to create my own library with charts.

Any idea how i can do this ?

Vincent

Depending on the effort you will have to put in such a component to create your own charts, I would recommend using charts such as those from Dundas for Reporting Services, because they are very experienced in building those components (even the basic ones that ship with RS are made by Dundas)

Jens K. Suessmeyer

http://www.sqlserver2005.de

Sunday, February 19, 2012

Chart expression error

I have a pretty simple chart which seems to work, but when I build it, I get
a warning that "the expression for the chart "chart1" contains an error:
operation is not valid due to the current state of the object". I've
experimented with a bunch of things to get rid of the warning,
unsuccessfully. May I have some suggestions for how to figure out exactly
what the warning is referencing?
--
Bob RogersBob, can you post a minimal RDL running against e.g. Northwind which
reproduces the issue. This would help in narrowing down and finding a
solution.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Bob Rogers" <BobRogers@.discussions.microsoft.com> wrote in message
news:11DF0CF7-5EE9-415E-934B-7F407604AFD2@.microsoft.com...
> I have a pretty simple chart which seems to work, but when I build it, I
get
> a warning that "the expression for the chart "chart1" contains an error:
> operation is not valid due to the current state of the object". I've
> experimented with a bunch of things to get rid of the warning,
> unsuccessfully. May I have some suggestions for how to figure out exactly
> what the warning is referencing?
> --
> Bob Rogers|||I did finally discover the problem: an error in an expression controlling the
"data label" within "point labels" accessed through the Data tab of a chart
property. There was no misbehavior apparent, so I just had to plug through
all the specifications. That was my first chart. Next time, I will pay
close attention to the appearance of a warning, while I still have some idea
what I had just done that might have caused it. I was hoping you would say
"turn on x debug option and read a stack" or something like that. Anyway,
thanks for the attempt.
"Robert Bruckner [MSFT]" wrote:
> Bob, can you post a minimal RDL running against e.g. Northwind which
> reproduces the issue. This would help in narrowing down and finding a
> solution.
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
> "Bob Rogers" <BobRogers@.discussions.microsoft.com> wrote in message
> news:11DF0CF7-5EE9-415E-934B-7F407604AFD2@.microsoft.com...
> > I have a pretty simple chart which seems to work, but when I build it, I
> get
> > a warning that "the expression for the chart "chart1" contains an error:
> > operation is not valid due to the current state of the object". I've
> > experimented with a bunch of things to get rid of the warning,
> > unsuccessfully. May I have some suggestions for how to figure out exactly
> > what the warning is referencing?
> > --
> > Bob Rogers
>
>

Tuesday, February 14, 2012

Char(10) breaking query

I have been working on a pretty ugly stored procedure recently, while debugging I added a char(10) to the end of each line of the SQL query so I could copy it to query analyzer(QA) and debug the SQL syntax output from of the stored procedure.

It had no effect on the stored procedure working, but when I copied the query to QA it got the error below, so I removed them all and added them in one line at a time to find the problem.

--Server: Msg 170, Level 15, State 1, Line 3
--Line 3: Incorrect syntax near ','.

Below are the 2 querys, the only difference is the Char(10) between Amt6 and Amt7!

http://www.rakbiz.com/download/broken.txt
http://www.rakbiz.com/download/working.txt

I also tried char(13) with same results.

any ideas why this is happening or how to add line breaks for readability without this problem?

Thanks for your help!Why is the code all on 1 line?

Ir's generated code isn't it.

Kind of hard to debug it without being formatted...|||You've been living in the *nix world too long! Windoze uses CRLF (aka Char(13) + Char(10) in SQL) instead of just LF (Char(10), aka NewLine) to separate lines.

-PatP|||Thanks Pat for the tip, that was it, I would never have guessed!

Actually I am from *ax backgroup ;)