Showing posts with label standard. Show all posts
Showing posts with label standard. 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

Cheapest way to purchase SQL Reporting Services

Within my department we have 1 copy of of vb studio.net standard and 2 copies
of vb studio.net enterprise and run sql server 2000.
One of the guys is writing a system which I have to report on using SQL
Reporting Services. As I don't have any .net product, do I have to purchase a
.net product to then get a development edition of SQL Reporting Services to
write any reports etc.
Looking for the cheapest way to be able to use SQL Reporting Services as I
work in the NHS (lucky me).
Any help will be much appreciated.
Thanks, MarkYour SQL license gives you RS. All you need to develop report is a copy of
VS. The cheapest way to aquire it is VB.net standard.
=?Utf-8?B?bWFya19tZW56aWVz?= <mark_menzies@.discussions.microsoft.com>
wrote in news:DC6ABF54-CFC9-417F-A898-1DB7FCB21549@.microsoft.com:
> Within my department we have 1 copy of of vb studio.net standard and 2
> copies of vb studio.net enterprise and run sql server 2000.
> One of the guys is writing a system which I have to report on using
> SQL Reporting Services. As I don't have any .net product, do I have to
> purchase a .net product to then get a development edition of SQL
> Reporting Services to write any reports etc.
> Looking for the cheapest way to be able to use SQL Reporting Services
> as I work in the NHS (lucky me).
> Any help will be much appreciated.
> Thanks, Mark
>|||Also, RS 2005 comes with a version of VS so no extra purchase is required.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Asher_N" <compguy666@.hotmail.com> wrote in message
news:Xns970F5808B7AFDcompguy666hotmailcom@.207.46.248.16...
> Your SQL license gives you RS. All you need to develop report is a copy of
> VS. The cheapest way to aquire it is VB.net standard.
> =?Utf-8?B?bWFya19tZW56aWVz?= <mark_menzies@.discussions.microsoft.com>
> wrote in news:DC6ABF54-CFC9-417F-A898-1DB7FCB21549@.microsoft.com:
>> Within my department we have 1 copy of of vb studio.net standard and 2
>> copies of vb studio.net enterprise and run sql server 2000.
>> One of the guys is writing a system which I have to report on using
>> SQL Reporting Services. As I don't have any .net product, do I have to
>> purchase a .net product to then get a development edition of SQL
>> Reporting Services to write any reports etc.
>> Looking for the cheapest way to be able to use SQL Reporting Services
>> as I work in the NHS (lucky me).
>> Any help will be much appreciated.
>> Thanks, Mark
>>
>

Sunday, February 19, 2012

chart axis

Does anyone know how one can control/modify/overwrite standard X and Y axis
in chart control? I am even reconsidering rewriting the whole char component
since it is far from what is must look like.
Thanks,
--
Martin Kulov
http://www.codeattest.com/blogs/martin
MCAD Charter Member
MCSD.NET Early Achiever
MCSD> Does anyone know how one can control/modify/overwrite standard X and Y
> axis in chart control?
My problem is that when I have two data series the X axis is grouped with
values from both series and makes it unreadable. How can I create two
separate X axis that can read easily?
Thanks,
--
Martin Kulov
http://www.codeattest.com/blogs/martin
MCAD Charter Member
MCSD.NET Early Achiever
MCSD
"Martin Kulov" <kulov@.bezbokluk.abv.bg> wrote in message
news:e$K3zardFHA.1036@.tk2msftngp13.phx.gbl...
> Does anyone know how one can control/modify/overwrite standard X and Y
> axis in chart control? I am even reconsidering rewriting the whole char
> component since it is far from what is must look like.
> Thanks,
> --
> Martin Kulov
> http://www.codeattest.com/blogs/martin
> MCAD Charter Member
> MCSD.NET Early Achiever
> MCSD
>

Sunday, February 12, 2012

Char and VarChar Datatype

Hi ,
What is the diff within Char and Varchar ? If define Char(10) in TableA
and this field is store the State code and the length is a non standard. User
can key in the length from 1 to 10.
Understand that I should define this field as VarChar(10) because is it a
no fixed length. But I don't really undertand what is the diff between this
two datatype in the backend structure ? It save the space ?
Travis Tan
In the backend char(10) is always stored as 10 characters (bytes), which
can give you problems when doing string comparisons because the string
will be padded with trailing spaces.
Varchar(10) will store a 32 bit integer (4 bytes) at the front of the
field to indicate the field length, followed by the actual number of
characters in the string.
So if you store a 2 character string in a varchar(10) it will use 6
bytes storage, if you store a 10 character string it will store 14
bytes.
HTH
Regards
Darren Gosbell [MCSD]
<dgosbell_at_yahoo_dot_com>
Blog: http://www.geekswithblogs.net/darrengosbell

Char and VarChar Datatype

Hi ,
What is the diff within Char and Varchar ? If define Char(10) in TableA
and this field is store the State code and the length is a non standard. Use
r
can key in the length from 1 to 10.
Understand that I should define this field as VarChar(10) because is it a
no fixed length. But I don't really undertand what is the diff between this
two datatype in the backend structure ? It save the space ?
Travis TanIn the backend char(10) is always stored as 10 characters (bytes), which
can give you problems when doing string comparisons because the string
will be padded with trailing spaces.
Varchar(10) will store a 32 bit integer (4 bytes) at the front of the
field to indicate the field length, followed by the actual number of
characters in the string.
So if you store a 2 character string in a varchar(10) it will use 6
bytes storage, if you store a 10 character string it will store 14
bytes.
HTH
Regards
Darren Gosbell [MCSD]
<dgosbell_at_yahoo_dot_com>
Blog: http://www.geekswithblogs.net/darrengosbell