Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Saturday, March 31, 2012

String Stripping

Hi,

I am trying to create a page that will check user input against a value in database. This page will have a text box for user to enter serial #.
Serial # length is variable but last 3 digit is always number.
For examples:
W04051234-PAY001 in this example code is 1234-PAY
W05051234-PAT002 in this example code is 1234-PAT

A12056040-G001 in this example code is 6040-G
B11056080-SU001 in this example code is 6080-s

Which is the best approach to extract CODE from user input?

Any help will be appriciated.

Thank

TekinUse the Regular Expression class, RegExp with a regular expression that looks for:
4 digits (or is it 3?) followed by
dash
followed by 1 or letters

That expression is:
\d{4}\-[A-Za-z]+
Actually,

I would like to Trancate first 5 digits and last 3 digits.

For examples:
W04051234-PAY001 in this example code is 1234-PAY
If you are attempting to strip a specific group of characters, the String class has numerous useful methods. I encourage you to read about the String class in the .net docs. I think the SubString() and Length() methods will be useful.

Monday, March 26, 2012

StringBuilder AppendLine dont print Line breaks in my emails!

Hello... I'm working with StringBuilder to create a message to send via text email.

My methos is:

StringBuilder retorno = new StringBuilder();

retorno.AppendLine ( "A lot of text 1" );
retorno.AppendLine ( "A lot of text 2" );

return retorno.ToString() ;

Well.. I this last line I return the text to the message, but the email arrives without line breaks.

What can i do? thanks!

if you email format is in HTML, then you can use tag "<BR>" to create a line break

StringBuilder sb = new StringBuilder();
sb.Append("A lot of text 1");
sb.Append("<br>");
sb.Append("A lot of text 2);
return retorno.ToString() ;

else

you may try using \r\n, sb.Append("XXX\\r\\nXXXX");


have you tried for this one ?? it shoud work as it worked for me..

 StringBuilder retorno =new StringBuilder(); retorno.AppendLine("A lot of text 1"); retorno.AppendLine("<br />"); //....append a <br /> Tag... retorno.AppendLine("A lot of text 2"); Response.Write(retorno.ToString());

hope it helps./.

Stringbuilder or table?

Hi

I am just wondering if i need dynamically create a html table, which way will be more efficient?

A. Use stringbuilder. For example, sb.append("<table border=0>""), for(i=0;i<10;i++){sb.append("<tr><td>abc</td></tr>")}, sb.append("</table>")

B. Use table control, t = new table, for(i=0;i<10;i++){tr=new tablerow, td=new tablecell, td.text="abc",tr.cells.add(td),t.rows.add(tr))

Thanks

~Mike


Hi

Honestly, i dont see it makes huge different

But I think B will quicker than A. because all table, row, cell are object. I think use object to create table will be faster than string built up.


Use the following code to test this:

private void RunTest(int count){ Stopwatch watch =new Stopwatch(); watch.Start();for (int i2 = 0; i2 < count; i2++) { Table table =new Table();for (int i = 0; i < 10; i++) { TableRow tr =new TableRow(); TableCell td =new TableCell(); td.Text ="abc"; tr.Cells.Add(td); table.Rows.Add(tr); } } watch.Stop(); Debug.WriteLine(watch.ElapsedMilliseconds); watch.Reset(); watch.Start();for (int i2 = 0; i2 < count; i2++) { StringBuilder sb =new StringBuilder(); sb.Append("<table border=0>");for (int i = 0; i < 10; i++) { sb.Append("<tr><td>abc</td></tr>"); } sb.Append("</table>"); } watch.Stop(); Debug.WriteLine(watch.ElapsedMilliseconds);} 

I did the test with a count of 1500 which should show a difference and let it run 4 times. The outputs are as follows:

22 // Table
4 // StringBuilder


29
5

22
4

26
4

But, as you won't to that 1,500 times, there won't be a lot of difference concerning the performance.


Hi all,

I think the best way is using Table, TableRow and TableCell objects. You can create a table with all cells and rows you want and navigate throw them using their structure. However, if you want to create a simple table that has only two cells or something similar, it's quicker to use StringBuilder object or a string variable.


If the table doesn't need to be a server control, then I think it would be a little more efficient to use a StringBuilder. I?haven't?done?any?tests,?but?writing?out raw?HTML?generally incurs?less?overhead?than?instantiang?controls?for?everything. Any performance difference between the two approaches is going to be negligable though, so personally i'd go for whatever you find the more readable.

A third, and possible better approach would be to put your information into a DataTable and bind it to a GridView, DataList or Repeater.
I'd say A is going to be slightly more efficient but as already pointed out it'll be negligible. I personally like the markup in my code to be neat when viewed so B would probably better achieve that, even if its only for me debugging its output when it goes skewey.

Saturday, March 24, 2012

Strong name for dll??

Heya,
I'm trying to create a strong name for a dll that I purchased. The dll is simply a PDF Merge dll. This dll is not something that I created. I want to know is it possible to give it a strong name? I've tried using al.exe (which comes with .net) and sn.exe. But I dont think I'm doing it right? Could someone please help me out. I'm using XP with .net 2003. Framework is v1.1.
The reason why I need this dll as a strong name is becuase I'm using Telstra as my web host and they support a hosted trust level. The only way I can use third party dll's is to give them a strong name...

Thankx in advance
Karl
:)Have you referred to MSDN yet?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconAssigningAssemblyStrongName.asp
Yes I have... And thankx for your reply... All help is appreciated...
I believe that the article is refering to creating strong names for dll's that you have created via code. I dont have the code for this dll. I purchased it. I only have the dll. So my question is can I give it a strong name still or do I have to have the code as well?

Thankx again in advance
Karl
You should have Code for Giving it a Strong Name.
Yes, I've tried to create a strong name once for a third-party DLL, but simply couldn't because I didn't have all parameters ready.
So any ideas on what I should do? Or what I could do?

Thankx again...
Karl
:)
Ask your web hosts to install it for you?
Thankx for your help... I will see if my web host will agree to that...
Thankx again
Karl
:)

Thursday, March 22, 2012

strong naming assembly

I am attempting trying to create an assembly with strong name
Here is what I have done:
called sn -k Tesstkey.snk
placed this code in my class:
using System.Reflection;
[assembly:AssemblyKeyFileAttribute("TestKey.snk")]
I am getting an error saying it cannot read the key file
First, Where should that .snk file go?
Second, What could cause that error?
DerrickHi,
You can give absolute path also for the .snk file.
I believe VS.NET IDE looks for the .snk file in the devenv.exe folder
itself.
"Derrick" <Derrick_no_spam@.geostrategies.ca> wrote in message
news:9LfOc.137615$ek5.83297@.pd7tw2no...
I am attempting trying to create an assembly with strong name
Here is what I have done:
called sn -k Tesstkey.snk
placed this code in my class:
using System.Reflection;
[assembly:AssemblyKeyFileAttribute("TestKey.snk")]
I am getting an error saying it cannot read the key file
First, Where should that .snk file go?
Second, What could cause that error?
Derrick
Hi Derrick,
As for the making stong-named asembly issue, I think you Shiva's suggestion
that use the full absolutte path of the key file is reasonable. Since
you're using the relative path of the file(haven't specify the full path),
I'm not sure whether the problem is cause by this. Anyway, please have a
try and if you have anyother findings, please also feel free to post here.
Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Derrick,
You can use a relative path for this, but it should be relative to the
compiled assembly, not the project file. For example, if you keep the key
file in the project root folder and your assemblies get compiled to <project
root>\bin\debug or <project root>\bin\release, then your relative path must
point up two directories. e.g.:
[assembly: AssemblyKeyFile(@."..\..\TestKey.snk")]
HTH,
Nicole
"Derrick" <Derrick_no_spam@.geostrategies.ca> wrote in message
news:9LfOc.137615$ek5.83297@.pd7tw2no...
>I am attempting trying to create an assembly with strong name
> Here is what I have done:
> called sn -k Tesstkey.snk
> placed this code in my class:
> using System.Reflection;
> [assembly:AssemblyKeyFileAttribute("TestKey.snk")]
> I am getting an error saying it cannot read the key file
> First, Where should that .snk file go?
> Second, What could cause that error?
> Derrick
>
>
>
Thanks for the help.
physical path wouldn't work because I have to move the projects between
machines. I used Nicole's suggestion to use the relative path of
"..\..\file.snk", and that worked. I had the file in the \bin\release\
folder, so that should have worked, but I can work with the relative path
approach.
Derrick
"Steven Cheng[MSFT]" <v-schang@.online.microsoft.com> wrote in message
news:Ic7VahfdEHA.2932@.cpmsftngxa10.phx.gbl...
> Hi Derrick,
> As for the making stong-named asembly issue, I think you Shiva's
suggestion
> that use the full absolutte path of the key file is reasonable. Since
> you're using the relative path of the file(haven't specify the full path),
> I'm not sure whether the problem is cause by this. Anyway, please have a
> try and if you have anyother findings, please also feel free to post here.
> Thanks.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
> Get Preview at ASP.NET whidbey
> http://msdn.microsoft.com/asp.net/whidbey/default.aspx
>
Thanks, Nicole
That worked
Derrick
"Nicole Calinoiu" <nicolec@.somewhere.net> wrote in message
news:OJjcaIkdEHA.3704@.TK2MSFTNGP09.phx.gbl...
> Derrick,
> You can use a relative path for this, but it should be relative to the
> compiled assembly, not the project file. For example, if you keep the key
> file in the project root folder and your assemblies get compiled to
<project
> root>\bin\debug or <project root>\bin\release, then your relative path
must
> point up two directories. e.g.:
> [assembly: AssemblyKeyFile(@."..\..\TestKey.snk")]
> HTH,
> Nicole
>
> "Derrick" <Derrick_no_spam@.geostrategies.ca> wrote in message
> news:9LfOc.137615$ek5.83297@.pd7tw2no...
>

strong naming assembly

I am attempting trying to create an assembly with strong name

Here is what I have done:
called sn -k Tesstkey.snk
placed this code in my class:
using System.Reflection;

[assembly:AssemblyKeyFileAttribute("TestKey.snk")]

I am getting an error saying it cannot read the key file

First, Where should that .snk file go?
Second, What could cause that error?

DerrickHi,

You can give absolute path also for the .snk file.

I believe VS.NET IDE looks for the .snk file in the devenv.exe folder
itself.

"Derrick" <Derrick_no_spam@.geostrategies.ca> wrote in message
news:9LfOc.137615$ek5.83297@.pd7tw2no...
I am attempting trying to create an assembly with strong name

Here is what I have done:
called sn -k Tesstkey.snk
placed this code in my class:
using System.Reflection;

[assembly:AssemblyKeyFileAttribute("TestKey.snk")]

I am getting an error saying it cannot read the key file

First, Where should that .snk file go?
Second, What could cause that error?

Derrick
Hi Derrick,

As for the making stong-named asembly issue, I think you Shiva's suggestion
that use the full absolutte path of the key file is reasonable. Since
you're using the relative path of the file(haven't specify the full path),
I'm not sure whether the problem is cause by this. Anyway, please have a
try and if you have anyother findings, please also feel free to post here.
Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Derrick,

You can use a relative path for this, but it should be relative to the
compiled assembly, not the project file. For example, if you keep the key
file in the project root folder and your assemblies get compiled to <project
root>\bin\debug or <project root>\bin\release, then your relative path must
point up two directories. e.g.:

[assembly: AssemblyKeyFile(@."..\..\TestKey.snk")]

HTH,
Nicole

"Derrick" <Derrick_no_spam@.geostrategies.ca> wrote in message
news:9LfOc.137615$ek5.83297@.pd7tw2no...
>I am attempting trying to create an assembly with strong name
> Here is what I have done:
> called sn -k Tesstkey.snk
> placed this code in my class:
> using System.Reflection;
> [assembly:AssemblyKeyFileAttribute("TestKey.snk")]
> I am getting an error saying it cannot read the key file
> First, Where should that .snk file go?
> Second, What could cause that error?
> Derrick
>
Thanks for the help.

physical path wouldn't work because I have to move the projects between
machines. I used Nicole's suggestion to use the relative path of
"..\..\file.snk", and that worked. I had the file in the \bin\release\
folder, so that should have worked, but I can work with the relative path
approach.

Derrick

"Steven Cheng[MSFT]" <v-schang@.online.microsoft.com> wrote in message
news:Ic7VahfdEHA.2932@.cpmsftngxa10.phx.gbl...
> Hi Derrick,
> As for the making stong-named asembly issue, I think you Shiva's
suggestion
> that use the full absolutte path of the key file is reasonable. Since
> you're using the relative path of the file(haven't specify the full path),
> I'm not sure whether the problem is cause by this. Anyway, please have a
> try and if you have anyother findings, please also feel free to post here.
> Thanks.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
> Get Preview at ASP.NET whidbey
> http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Thanks, Nicole

That worked

Derrick
"Nicole Calinoiu" <nicolec@.somewhere.net> wrote in message
news:OJjcaIkdEHA.3704@.TK2MSFTNGP09.phx.gbl...
> Derrick,
> You can use a relative path for this, but it should be relative to the
> compiled assembly, not the project file. For example, if you keep the key
> file in the project root folder and your assemblies get compiled to
<project
> root>\bin\debug or <project root>\bin\release, then your relative path
must
> point up two directories. e.g.:
> [assembly: AssemblyKeyFile(@."..\..\TestKey.snk")]
> HTH,
> Nicole
>
> "Derrick" <Derrick_no_spam@.geostrategies.ca> wrote in message
> news:9LfOc.137615$ek5.83297@.pd7tw2no...
> >I am attempting trying to create an assembly with strong name
> > Here is what I have done:
> > called sn -k Tesstkey.snk
> > placed this code in my class:
> > using System.Reflection;
> > [assembly:AssemblyKeyFileAttribute("TestKey.snk")]
> > I am getting an error saying it cannot read the key file
> > First, Where should that .snk file go?
> > Second, What could cause that error?
> > Derrick

Strong Password encryption program?

I have a web-based program that will be going to an external web server and
want to create a logon process. I am using forms authentication, passing
encryption with salt, but want to force the user to create passwords with
rules: combinations of numbers & letters, at least one character caps,
things like that, like we would on a a network, and to change the password
every x amount of months. Can anyone point me in the right direction as to
any articles that may help me do this, or the correct process?

Thanks for your help.This is handled at multiple places:

1) Forms authentication allows a user to login into the system for a
session or for a certain amount of time. The way you are handling is
good enough.
2) To have a set of rules for a password, you may use regular
expressions on ASP.NET password textboxes. Search google.
Alternatively, you can write your own logic to validate in code-behind
file or have a trigger in the database of password field, that verifies
the requirement.
3) Password expiry should be maintained by your database logic.
Whenever, a password is updated, update the last updated date and
whenever user login, check if the last updated date is beyond the valid
date time frame. If so, force user to create a new password.

If there are any other ways, please contribute. I'll love to know more
varieties.

Thanks,
Aru
Hello KatMagic,

If you haven't already, take a look at the SqlMembershipProvider api in
ASP.NET 2.0. It has some of what you want built in:

> Configurable password strength
> Automatic lockout
> Minimum number of non-alphanumeric
> Security question/answer
> ...

The membership data are stored in SQL so you have access to the tables,
stored procedures, and functions if you want to customize.

--
enjoy - brians
http://www.limbertech.com

Strong Password encryption program?

I have a web-based program that will be going to an external web server and
want to create a logon process. I am using forms authentication, passing
encryption with salt, but want to force the user to create passwords with
rules: combinations of numbers & letters, at least one character caps,
things like that, like we would on a a network, and to change the password
every x amount of months. Can anyone point me in the right direction as to
any articles that may help me do this, or the correct process?
Thanks for your help.This is handled at multiple places:
1) Forms authentication allows a user to login into the system for a
session or for a certain amount of time. The way you are handling is
good enough.
2) To have a set of rules for a password, you may use regular
expressions on ASP.NET password textboxes. Search google.
Alternatively, you can write your own logic to validate in code-behind
file or have a trigger in the database of password field, that verifies
the requirement.
3) Password expiry should be maintained by your database logic.
Whenever, a password is updated, update the last updated date and
whenever user login, check if the last updated date is beyond the valid
date time frame. If so, force user to create a new password.
If there are any other ways, please contribute. I'll love to know more
varieties.
Thanks,
Aru
Hello KatMagic,
If you haven't already, take a look at the SqlMembershipProvider api in
ASP.NET 2.0. It has some of what you want built in:

> Configurable password strength
> Automatic lockout
> Minimum number of non-alphanumeric
> Security question/answer
> ...
The membership data are stored in SQL so you have access to the tables,
stored procedures, and functions if you want to customize.
enjoy - brians
http://www.limbertech.com

Strongly Type Datasets

I am trying to create a strongly typed dataset is VS 2005 with the VS
creating the stored procedures. It won't create the stored procedures. The
SQL script it generates is based on a SQL login so the script looks
something like:

DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE

these scripts won't work until I change the script to:

DROP PROCEDURE dbo.WEB_PAGE_UPDATE

What am I doing wrong? I suspect I doing my connectionstring wrong in some
way or my permissions are wrong in SQL Server.

Regards, Chris.Is there a setting for the database "Schema Name" somewhere on the
properties of the data set? That's what's being prepended to the table name.

"Chris" <nospam@.nospam.comwrote in message
news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>I am trying to create a strongly typed dataset is VS 2005 with the VS
>creating the stored procedures. It won't create the stored procedures. The
>SQL script it generates is based on a SQL login so the script looks
>something like:
>
DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
>
these scripts won't work until I change the script to:
>
DROP PROCEDURE dbo.WEB_PAGE_UPDATE
>
What am I doing wrong? I suspect I doing my connectionstring wrong in some
way or my permissions are wrong in SQL Server.
>
Regards, Chris.
>


No I can't find it. Any clues where abouts I might find it. I have looked on
the properties on of the dataset etc.

"KJ" <n_o_s_p_a__M@.Mail.comwrote in message
news:OFjUR$GoHHA.716@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Is there a setting for the database "Schema Name" somewhere on the
properties of the data set? That's what's being prepended to the table
name.
>
"Chris" <nospam@.nospam.comwrote in message
news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>>I am trying to create a strongly typed dataset is VS 2005 with the VS
>>creating the stored procedures. It won't create the stored procedures. The
>>SQL script it generates is based on a SQL login so the script looks
>>something like:
>>
>DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
>>
>these scripts won't work until I change the script to:
>>
>DROP PROCEDURE dbo.WEB_PAGE_UPDATE
>>
>What am I doing wrong? I suspect I doing my connectionstring wrong in
>some way or my permissions are wrong in SQL Server.
>>
>Regards, Chris.
>>


>
>


Which version of SQL Server? If 2005, go to the properties page of the login
you are using (via Management Studio), and check the value for Default
Schema for that login. My guess is that it's not dbo. But this is just a
guess.

"Chris" <nospam@.nospam.comwrote in message
news:OxkTYdHoHHA.4124@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

No I can't find it. Any clues where abouts I might find it. I have looked
on the properties on of the dataset etc.
>
"KJ" <n_o_s_p_a__M@.Mail.comwrote in message
news:OFjUR$GoHHA.716@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

>Is there a setting for the database "Schema Name" somewhere on the
>properties of the data set? That's what's being prepended to the table
>name.
>>
>"Chris" <nospam@.nospam.comwrote in message
>news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>>>I am trying to create a strongly typed dataset is VS 2005 with the VS
>>>creating the stored procedures. It won't create the stored procedures.
>>>The SQL script it generates is based on a SQL login so the script looks
>>>something like:
>>>
>>DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
>>>
>>these scripts won't work until I change the script to:
>>>
>>DROP PROCEDURE dbo.WEB_PAGE_UPDATE
>>>
>>What am I doing wrong? I suspect I doing my connectionstring wrong in
>>some way or my permissions are wrong in SQL Server.
>>>
>>Regards, Chris.
>>>


>>
>>


>
>


Sorry I must be missing something. When you say "check for default schema",
I can't find it it. It is SQL 2005. I have gone to the login propeties page
of the login (in SQL 2005), gone to user mapping and put the default scheme
over to do_owner but the sql scripts generated are still this same in VS
2005

"KJ" <n_o_s_p_a__M@.Mail.comwrote in message
news:O7IrnYJoHHA.1476@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Which version of SQL Server? If 2005, go to the properties page of the
login you are using (via Management Studio), and check the value for
Default Schema for that login. My guess is that it's not dbo. But this is
just a guess.
>
"Chris" <nospam@.nospam.comwrote in message
news:OxkTYdHoHHA.4124@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>No I can't find it. Any clues where abouts I might find it. I have looked
>on the properties on of the dataset etc.
>>
>"KJ" <n_o_s_p_a__M@.Mail.comwrote in message
>news:OFjUR$GoHHA.716@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

>>Is there a setting for the database "Schema Name" somewhere on the
>>properties of the data set? That's what's being prepended to the table
>>name.
>>>
>>"Chris" <nospam@.nospam.comwrote in message
>>news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...
>>I am trying to create a strongly typed dataset is VS 2005 with the VS
>>creating the stored procedures. It won't create the stored procedures.
>>The SQL script it generates is based on a SQL login so the script looks
>>something like:
>>
>>>DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
>>
>>>these scripts won't work until I change the script to:
>>
>>>DROP PROCEDURE dbo.WEB_PAGE_UPDATE
>>
>>>What am I doing wrong? I suspect I doing my connectionstring wrong in
>>>some way or my permissions are wrong in SQL Server.
>>
>>>Regards, Chris.
>>
>>>
>>>


>>
>>


>
>


"db_owner" is a role, not a schema; "dbo" is a schema.

When you look at the name of the table in the Object Explorer (of Management
Studio), what is it? Is it dbo.TableName, or WebManagerV2.TableName?

"Chris" <nospam@.nospam.comwrote in message
news:O7PiG6KoHHA.5052@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Sorry I must be missing something. When you say "check for default
schema", I can't find it it. It is SQL 2005. I have gone to the login
propeties page of the login (in SQL 2005), gone to user mapping and put
the default scheme over to do_owner but the sql scripts generated are
still this same in VS 2005
>
>
"KJ" <n_o_s_p_a__M@.Mail.comwrote in message
news:O7IrnYJoHHA.1476@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>Which version of SQL Server? If 2005, go to the properties page of the
>login you are using (via Management Studio), and check the value for
>Default Schema for that login. My guess is that it's not dbo. But this is
>just a guess.
>>
>"Chris" <nospam@.nospam.comwrote in message
>news:OxkTYdHoHHA.4124@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>>No I can't find it. Any clues where abouts I might find it. I have
>>looked on the properties on of the dataset etc.
>>>
>>"KJ" <n_o_s_p_a__M@.Mail.comwrote in message
>>news:OFjUR$GoHHA.716@.TK2MSFTNGP05.phx.gbl...
>>>Is there a setting for the database "Schema Name" somewhere on the
>>>properties of the data set? That's what's being prepended to the table
>>>name.
>>
>>>"Chris" <nospam@.nospam.comwrote in message
>>>news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...
>>I am trying to create a strongly typed dataset is VS 2005 with the VS
>>creating the stored procedures. It won't create the stored procedures.
>>The SQL script it generates is based on a SQL login so the script looks
>>something like:
>>
>>DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
>>
>>these scripts won't work until I change the script to:
>>
>>DROP PROCEDURE dbo.WEB_PAGE_UPDATE
>>
>>What am I doing wrong? I suspect I doing my connectionstring wrong in
>>some way or my permissions are wrong in SQL Server.
>>
>>Regards, Chris.
>>
>>
>>
>>>
>>>


>>
>>


>
>

Strongly Type Datasets

I am trying to create a strongly typed dataset is VS 2005 with the VS
creating the stored procedures. It won't create the stored procedures. The
SQL script it generates is based on a SQL login so the script looks
something like:
DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
these scripts won't work until I change the script to:
DROP PROCEDURE dbo.WEB_PAGE_UPDATE
What am I doing wrong? I suspect I doing my connectionstring wrong in some
way or my permissions are wrong in SQL Server.
Regards, Chris.Is there a setting for the database "Schema Name" somewhere on the
properties of the data set? That's what's being prepended to the table name.
"Chris" <nospam@.nospam.com> wrote in message
news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...
>I am trying to create a strongly typed dataset is VS 2005 with the VS
>creating the stored procedures. It won't create the stored procedures. The
>SQL script it generates is based on a SQL login so the script looks
>something like:
> DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
> these scripts won't work until I change the script to:
> DROP PROCEDURE dbo.WEB_PAGE_UPDATE
> What am I doing wrong? I suspect I doing my connectionstring wrong in some
> way or my permissions are wrong in SQL Server.
> Regards, Chris.
>
Which version of SQL Server? If 2005, go to the properties page of the login
you are using (via Management Studio), and check the value for Default
Schema for that login. My guess is that it's not dbo. But this is just a
guess.
"Chris" <nospam@.nospam.com> wrote in message
news:OxkTYdHoHHA.4124@.TK2MSFTNGP02.phx.gbl...
> No I can't find it. Any clues where abouts I might find it. I have looked
> on the properties on of the dataset etc.
> "KJ" <n_o_s_p_a__M@.Mail.com> wrote in message
> news:OFjUR$GoHHA.716@.TK2MSFTNGP05.phx.gbl...
>
No I can't find it. Any clues where abouts I might find it. I have looked on
the properties on of the dataset etc.
"KJ" <n_o_s_p_a__M@.Mail.com> wrote in message
news:OFjUR$GoHHA.716@.TK2MSFTNGP05.phx.gbl...
> Is there a setting for the database "Schema Name" somewhere on the
> properties of the data set? That's what's being prepended to the table
> name.
> "Chris" <nospam@.nospam.com> wrote in message
> news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...
>
Sorry I must be missing something. When you say "check for default schema",
I can't find it it. It is SQL 2005. I have gone to the login propeties page
of the login (in SQL 2005), gone to user mapping and put the default scheme
over to do_owner but the sql scripts generated are still this same in VS
2005
"KJ" <n_o_s_p_a__M@.Mail.com> wrote in message
news:O7IrnYJoHHA.1476@.TK2MSFTNGP03.phx.gbl...
> Which version of SQL Server? If 2005, go to the properties page of the
> login you are using (via Management Studio), and check the value for
> Default Schema for that login. My guess is that it's not dbo. But this is
> just a guess.
> "Chris" <nospam@.nospam.com> wrote in message
> news:OxkTYdHoHHA.4124@.TK2MSFTNGP02.phx.gbl...
>
"db_owner" is a role, not a schema; "dbo" is a schema.
When you look at the name of the table in the Object Explorer (of Management
Studio), what is it? Is it dbo.TableName, or WebManagerV2.TableName?
"Chris" <nospam@.nospam.com> wrote in message
news:O7PiG6KoHHA.5052@.TK2MSFTNGP04.phx.gbl...
> Sorry I must be missing something. When you say "check for default
> schema", I can't find it it. It is SQL 2005. I have gone to the login
> propeties page of the login (in SQL 2005), gone to user mapping and put
> the default scheme over to do_owner but the sql scripts generated are
> still this same in VS 2005
>
> "KJ" <n_o_s_p_a__M@.Mail.com> wrote in message
> news:O7IrnYJoHHA.1476@.TK2MSFTNGP03.phx.gbl...
>
http://Pamela-Anderson-in-nylons.in...p?movie=1673286

Strongly-typed Datasets in ASP.NET 2.0

Hello,

In ASP.NET 1.1, I followed this data access methodology:

At design time
- Create a strongly typed dataset
- Add this dataset to a form and bind controls to the dataset using
the designer

At run time
- Fill dataset with data on the first load of the page
- Handle all Add/Edit/Delete operations against the in-memory copy
of my dataset
- Persist the dataset between postbacks in session
- Give users the ability to Save or Cancel changes, which either
persists the changes to the database or discards them.

It worked like a charm -- there were only two trips to the database --
in the very beginning and at the very end. In memory manipulations were
very fast. And, more importantly, my productivity was high because I
was able to use design features of the Visual Studio.

It seems that in 2005, if I were to pursue the same methodology, things
would be harder, not easier.

- It appears that the only way to bind a dataset to a gridview is
through the ObjectDataSource. This binds to table adapters, not the
actual dataset, so, the database gets hit on each update.

- DataSource property is gone from the design view, so I no longer can
use the design features of Visual Studio, if I were to directly bind to
a dataset.

- There is no out of the box feature to persist a dataset between
postbacks. So, like in 1.1, if I were to go this route, I would have to
persist it in session.

I was wondering if there is anybody out there who used the 1.1 data
access in a similar fashion, and how you adapted to 2.0.

Thank you for your comments.

Evgueni

Hi Evgueni,

You can create a strongly typed DS without table adapters also. Simplest way is to just open the DS in the designer and delete the adapter part. You can then use this DS to bind to a gridView (like in 1.1) but you need to manually write code to add rows to it. Alternatively, you can use an ObjectDatasource and let it handle the DB code itself.

HTH,

Vivek


Wouldn't that be great, if there was a data source object that would out of the box:

- bind directly to a dataset, not table adapters
- know how to persist the dataset between postbacks (maybe different persistence models such as session or cache)
- have the load and update methods to interact with the database

Basically, Windows Forms pattern -- but in a stateless environment. This would greatly assist us with creating cancellable forms such as wizard and complex master/child forms.

Am I talking non-sense, or is it something that people could use in ASP.NET?


Data source controls controls can either directly connect to a data store such as a DB or XML files, or to a business object (such as a strongly typed dataset). They act like a "broker" dealing with the manipulation of data so that the developer is spared of writing too much standard data access code. So an object data source can bind directly to a dataset (and you need to create a strongly typed dataset for it, or a custom business object) and also support caching. When using typed datasets, the VS 2005 designer creates TableAdapters for the Datasets, which is an advanced and quite useful feature considering the fact that TableAdapters extend DataAdpaters.

Now when we talk about binding directly to a dataset, this we can easily do, but tableAdapeters help us to avoid writing CRUD code (with the help of VS designer) and save time. You can very easily attach Load and Update methods using TableAdapter to bind to a particular table in the DB. So my point is that TableAdapters are just some "nitro boosted" form of DataAdapters, and while using them you are infact binding with the typed Datasets only.

Summarising, all your requirements can be easily met with the new ADO.NET and VS 2005 designer features in .NET 2.0.

Let me know if you need more details.

Vivek


Vivek, thank you for your response.

I understand that what I am asking for can be done in .NET 2.0. My point is that you actually have to write code if you want to bind directly to a dataset, and I don't want to do thatSmile. For example, I want to bind directly to the dataset, and maintain a full design-time experience like I had in 2003. I can't do that now because the Data Source property is not available in the designer. Am I missing something here?

Evgueni


Evgueni,

You can use the DataSource property for the GridView in the code behind, but the reason it is not there in the Properties window is due to the fact that if we bind a gridview to a non-datasourcecontrol object, we need to provide custom paging. So it is advisable to use an ObjectDataSource which is connected to a strongly typed dataset with a gridview. All relevant designer properties would be supported.

Let me know if you still face issues with this approach.

Vivek

Struct Default Constructor Question

When I create a new object of type struct, I want objects to be created for each member variable in that struct. For example:

private struct Strings {
public string s1;
public string s2;
}

Strings myStrings = new Strings();

Based on what I read, the default constructor for the struct should automatically initalize s1 and s2 to string.Empty implicitly. However, doing something like int size = myStrings.s1.Length throws a NullReferenceException. I don't understand why myStrings.s1 does not exist. Aren't s1 and s2 created automatically when I create a new object called myStrings??

Hello anonim:

> Based on what I read, the default constructor for the struct should automatically initalize s1 and s2 to string.Empty implicitly.

I'm afraid this is not correct. There's no implicit initialization of objects anywhere and your strings won't be created automatically.

So here is how one commonly would write it:

private struct Strings {
public string s1;
public string s2;

public Strings() {
s1 = String.Empty;
s2 = String.Empty;
}
}

Strings myStrings = new Strings();

Feel free to ask more.

HTH. -LV


Ludovico, thanks for your reply.

Per the MSDN [link]:

"Unlike a class, a struct is not permitted to declare a parameterlessinstance constructor. Instead, every struct implicitly has aparameterless instance constructor that always returns the value thatresults from setting all value type fields to their default value andall reference type fields to null. A struct can declare instance constructors having parameters."

So based on that, you cannot create a parameterless constructor for any struct (public Strings() { ...} does not compile - try it).

The statement above says all value type fields are set to their default value, and all reference type fields are set to null. Based on the fact that the implicit constructor does not initialize the string variables in my struct, I can safely assume that these string variables are reference types, correct? So, what I must do is to create a constructor with parameters and use that to instantiate and initialize the struct member variables.

Thanks for your help.

anonim:

> Unlike a class, a struct is not permitted to declare a parameterless instance constructor.

Yes, you are right, sorry...

> The statement above says all value type fields are set to their default value, and all reference type fields are set to null. Based on the fact that the implicit constructor does not initialize the string variables in my struct, I can safely assume that these string variables are reference types, correct?

Yes: String is a class, so strings are reference types, not value types.

> So, what I must do is to create a constructor with parameters and use that to instantiate and initialize the struct member variables.

Right again!

Cheers. :) -LV


Thank you much!

struct inside method

Hi all!

I have the need to create a struct that will only be usefull inside a method. I have been trying to do so by doing something like this:


public class myClass
{
public void myMethod
{
private struct myStruct
{ int myInt; }
}
}

I a keep getting compiler errors such as:


} expected

Can somebody give me any clue on this?

Thanks in advance!

LAMScoping a struct to a method isn't allowed. You can scope a struct to a class, though, using the private keyword and embedding it inside a class.


public class MyClass
{
private struct MyStruct { int MyInt; }
public void MyMethod()
{
MyStruct x = new MyStruct();
}
}

This should work perfectly fine.

Nick

Structure/Array Question - Easy

I have a Structure and need to create array of Structures for example... How do I accomplish this?

Structure MyStruct

Dim Input1 As String

Dim Input2 As String

End Structure

dim t() as MyStruct

try this

Dim myarray(10)As MyStruct

(if you want the length of the array to be 10)


This is your Structure:

Structure myStruct
Dim Input1 As String
Dim Input2 As String
End Structure

if you want to have an array of your structure with a fix length... then you can do it as..

Dim t(10) As myStruct

if you want to have an array of your structure with dynamic length... i mean if you are not sure what is the length then... you can do it as...

Dim t1() As myStruct
Dim iRow As Integer = 0
While (True) '...an endless loop... just to show example...
ReDim Preserve t1(iRow)
t1(iRow) = New myStruct
t1(iRow).Input1 = ""
t1(iRow).Input2 = ""
iRow += 1
End While

hope it helps./.

Structures vs Variables - Or can I even do this?

Hello all-
I need to pass around the details of a db record a few times and was wondering about using structures. If I create a structure something like the one listed below in one of my XXX.vb files, can I use it like a variable?

**USERDB.VB File**
Public Structure UserDetails
puplic FirstName as string
public LastName as string
End Structure

Public Function GetUserDetails(byval UID as Integer) as UserDetails
**Database crap here**
GetUserDetails.FirstName = objDR("FirstName").tostring
GetUserDetails.LastName = objDR("LastName").tostring
End Function

**WEBFORM1.ASPX.VB**
Private Sub ShowUser(byval UID as integer)
Dim objUserDetails as UserDetails
objUserDetails = GetUserDetails(UID)
lblFirstName.text = objUserDetails.FirstName
lblLastName.text = objUserDetails.LastName
End Sub

Sorry so long. Do I need to destroy the objects when done with them?

Thanks,
DougMaybe use a class instead? Any help would be great!

Tuesday, March 13, 2012

Struggling With Concept

Hi Folks,
As you may know I'm new to ASP.NET and Im having trouble
grappling with one concept.
If I create a user control and place it on a page I can access its public
properties through a pre-render block, But I cant access its public
properties via code. In say the Page_Load event.
Surely if the control is registered, when the Page_Load Loads, it must have
access to the UserControl Object otherwise whats the point?
Please tell me where Im going wrong !
CheersHi,
What you need to do is access the usercontrol directly, for example: -
Page_Load(...)
{
((myusercontroltype)this.FindControl("UserControlInstance1")).<Property>
}
Hth,
Phil Winstanley
Microsoft ASP.NET MVP
http://www.myservicescentral.com
Thank you so much for that, I knew it should be possible, but I must have
missed that Method somehow. I tried this instantly and it work just
absolutely fine.
Thanks Again for your help.
Best Regards - OHM
"Phil Winstanley [Microsoft MVP ASP.NET]" <phil@.winstanley.name> wrote i
n
message news:caep52$9ft@.odah37.prod.google.com...
> Hi,
> What you need to do is access the usercontrol directly, for example: -
> Page_Load(...)
> {
> ((myusercontroltype)this.FindControl("UserControlInstance1")).<Property>
> }
> Hth,
> Phil Winstanley
> Microsoft ASP.NET MVP
> http://www.myservicescentral.com
>
You can also declare the control at the module level and use the withevents
keyword to expose its events if they are needed. Then you can reference the
control via the code editor.
#Region " Web Form Designer Generated Code "
'Instantiate the control here and you can use it throughout the page by
name.
Protected WithEvents MyUserControl As New MyUserControl
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
With Me.MyUserControl
.DataSource = SomeDataSource
.Text = "SomeValue"
.SomeOtherProperty = "SomeOtherValue"
End With
End If
End Sub
"One Handed Man ( OHM#)" <news.microsoft.com> wrote in message
news:uazb75GUEHA.1048@.tk2msftngp13.phx.gbl...
> Hi Folks,
> As you may know I'm new to ASP.NET and Im having trouble
> grappling with one concept.
> If I create a user control and place it on a page I can access its public
> properties through a pre-render block, But I cant access its public
> properties via code. In say the Page_Load event.
> Surely if the control is registered, when the Page_Load Loads, it must
> have
> access to the UserControl Object otherwise whats the point?
> Please tell me where Im going wrong !
> Cheers
>

Struggling With Concept

Hi Folks,
As you may know I'm new to ASP.NET and Im having trouble
grappling with one concept.

If I create a user control and place it on a page I can access its public
properties through a pre-render block, But I cant access its public
properties via code. In say the Page_Load event.

Surely if the control is registered, when the Page_Load Loads, it must have
access to the UserControl Object otherwise whats the point?

Please tell me where Im going wrong !

CheersYou can also declare the control at the module level and use the withevents
keyword to expose its events if they are needed. Then you can reference the
control via the code editor.

#Region " Web Form Designer Generated Code "
'Instantiate the control here and you can use it throughout the page by
name.
Protected WithEvents MyUserControl As New MyUserControl

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
With Me.MyUserControl
.DataSource = SomeDataSource
.Text = "SomeValue"
.SomeOtherProperty = "SomeOtherValue"
End With
End If
End Sub

"One Handed Man ( OHM#)" <news.microsoft.com> wrote in message
news:uazb75GUEHA.1048@.tk2msftngp13.phx.gbl...
> Hi Folks,
> As you may know I'm new to ASP.NET and Im having trouble
> grappling with one concept.
> If I create a user control and place it on a page I can access its public
> properties through a pre-render block, But I cant access its public
> properties via code. In say the Page_Load event.
> Surely if the control is registered, when the Page_Load Loads, it must
> have
> access to the UserControl Object otherwise whats the point?
> Please tell me where Im going wrong !
> Cheers

Stuck again

Hi Guys

Here is my problem

I have a sql database with a field voucherRate(int4) that contains a figure that will be used to create a discount.

Here is my code so far


'Declare the discount string
dim strDiscount as double
'declare the total string
dim strTotal as double = 10
Sub Page_Load
'set up connection to db
Dim conNorthwind As SqlConnection
Dim dsEmployees As DataSet
dsEmployees = New Dataset

' Retrieve records from database
conNorthwind = New SqlConnection( "server=(local);uid=sa;pwd=*****;database=dbSQL" )
Dim daEmployees As SQLDataAdapter
daEmployees = New SqlDataAdapter( "Select voucherRate from vouchers", conNorthwind )
daEmployees.Fill( dsEmployees, "voucherRate" )

conNorthwind.Close()
strDiscount = daEmployees( "VoucherRate" )
End Sub

OK what I need to add but am really struggling with is this;
strDiscount = "DataSet Voucher Rate" / 100 * strTotal

What would be the correct syntax for creating this stringFirst of all...
I find your variable names very different...
I am not sure why you have "str" before all your variables...
Check out MSDN site for naming convention...

Anyhow...
here's the code to access your voucherRate field...


conNorthwind.close()

strDiscount = CType(dsEmployees.Tables(0).Rows(0).Item("voucherRate"),Integer)/100 * strTotal

But please note that your dataset might have more than one records and hence you have to loop through the dataset to calculate discount for all the records...

stuck in the beginning!

Hi!
I tried to create my first ASP .NET application using VBScript, i recenetly installed .NET, i added some controls like a textbox, a button and few labels. When i try to view the web page, only the labels can be seen but not any other controls. When i try to debug it, i get a messadge saying that i need to install some components. Cany anyone help me out? Thank you.First of all, ASP.NET uses VB.NET not VBScript but I assume that it was just a typo on your behalf (confusing ASP and ASP.NET). In order to get it to work you'll need to install ASP.NET on your IIS server, as follows:
1. go to the command prompt (Start, Run, cmd.exe)
2. go to the Windows\Microsoft.NET\Framework\v1.1.4322 folder
3. execute aspnet_regiis.exe /i

In order to do this, make sure the .NET Framework is installed on the system (available through Windows Update or via the MSDN website). I assume you're using IIS to develop ASP.NET apps in this case. To view your pages, save them in the inetpub\wwwroot folder and go to http://localhost/thepage.aspx (replace theplace.aspx of course) to view the result.
Thanks a lot man. This will get me going. And i apologize for the typo. Thanks again.

stuck with the guided tutorial

Hi all,

i am new to asp.net and just starting out with WebMatrix
guided tour tutorial from ASP.NET. I managed to create the
myfirstpage.aspx (Label, text, calendar, button) and ran
it with webmatrix server smoothly.

However when I tried to create and use the IIS Virtual
Root (under Start Web Application), the browser only
showed the Label part. It also showed an exclamation mark
(error sign). I even copied the myfirstpage.aspx file to
the default web folder (\Inetpub\wwwroot) but to no avail.

What did I do wrong?

I did install everything, right:
IIS
the .NEt framework
webmatrix
sql2kdesksp3.exe
and mdac 2.7

The system runs on Windows 2000 Pro SP4 and it has its own
static IP.

I tried the iis ftp and web using regular html and it
works fine... but not the myfirstpage.aspx.

HElppppp.This could be becuase asp.net is not registered in the iis. try the following:

cd %windir%\microsoft.net\framework\v1.0.3705
aspnet_regiis -i

HTH

-aka
Alleluia... Thank you, it works. Thanks a bunch.

mitoshie