Showing posts with label wrong. Show all posts
Showing posts with label wrong. Show all posts

Saturday, March 31, 2012

System.FormatException: Input string was not in a correct format

Hello all,

I'm looking for a long time to find out what's wrong, but I can't find the mistake...
The connection to the database works correctly (Select,..), but when I set up the Insert-Command by clicking a button I get the following exception. Does anybody can help me and tell me what's wrong?!

Thank you for helping!

Exception:
System.FormatException: Input string was not in a correct format. at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.String.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at System.Data.OleDb.OleDbParameter.GetParameterValue() at System.Data.OleDb.OleDbParameter.GetParameterScale() at System.Data.OleDb.OleDbParameter.BindParameter(Int32 i, DBBindings bindings, tagDBPARAMBINDINFO[] bindInfo) at System.Data.OleDb.OleDbCommand.CreateAccessor() at System.Data.OleDb.OleDbCommand.InitializeCommand(CommandBehavior behavior, Boolean throwifnotsupported) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at roomplaner.ObjektHinzu.Anlegen_Click(Object sender, EventArgs e) in C:\Inetpub\...\ObjektHinzu.aspx.vb:line 107

line 107 --> Command.ExecuteNonQuery()


Dim Command As New OleDbCommand

'create OleDb database connection
Dim SQL_CONNECTION_STRING As String = "Provider=SQLOLEDB;Server=...;...."
Command.Connection = New OleDbConnection(SQL_CONNECTION_STRING)

'create SQL statement for INSERT into table
Command.CommandText = "INSERT INTO t_object (Name, ObjectType, Category, Manufactor, Length, Width, Height, Text_Short, Text_Long, URL_Pic_Small, URL_Pic_Big, URL_Pic_Plan, URL_VET, VET_ObjectName, Material, Color, Price, ObjectLink, Comment, MaxSceneCount) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
Command.CommandType = CommandType.Text

'add input parameters and values to INSERT statement
Command.Parameters.Add("@dotnet.itags.org.Name", OleDbType.VarChar, 100).Value = O_Name.Text
Command.Parameters.Add("@dotnet.itags.org.ObjectType", OleDbType.BigInt, 8).Value = O_ObjectType.SelectedValue
Command.Parameters.Add("@dotnet.itags.org.Category", OleDbType.BigInt, 8).Value = O_Category.SelectedValue
Command.Parameters.Add("@dotnet.itags.org.Manufactor", OleDbType.BigInt, 8).Value = O_Manufactor.SelectedValue
Command.Parameters.Add("@dotnet.itags.org.Length", OleDbType.Integer, 4).Value = O_Length.Text
Command.Parameters.Add("@dotnet.itags.org.Width", OleDbType.Integer, 4).Value = O_Width.Text
Command.Parameters.Add("@dotnet.itags.org.Height", OleDbType.Integer, 4).Value = O_Height.Text
Command.Parameters.Add("@dotnet.itags.org.Text_Short", OleDbType.VarChar, 100).Value = O_Text_Short.Text
Command.Parameters.Add("@dotnet.itags.org.Text_Long", OleDbType.VarChar, 500).Value = O_Text_Long.Text

Command.Parameters.Add("@dotnet.itags.org.URL_Pic_Small", OleDbType.VarChar, 100).Value = "0"
Command.Parameters.Add("@dotnet.itags.org.URL_Pic_Big", OleDbType.VarChar, 100).Value = "0"
Command.Parameters.Add("@dotnet.itags.org.URL_Pic_Plan", OleDbType.VarChar, 100).Value = "0"

Command.Parameters.Add("@dotnet.itags.org.URL_VET", OleDbType.VarChar, 100).Value = "0"
Command.Parameters.Add("@dotnet.itags.org.VET_ObjectName", OleDbType.VarChar, 50).Value = O_VET_ObjectName.Text
Command.Parameters.Add("@dotnet.itags.org.Material", OleDbType.BigInt, 8).Value = O_Material.SelectedValue
Command.Parameters.Add("@dotnet.itags.org.Color", OleDbType.BigInt, 8).Value = O_Color.SelectedValue
Command.Parameters.Add("@dotnet.itags.org.Price", OleDbType.VarChar, 50).Value = O_Price.Text
Command.Parameters.Add("@dotnet.itags.org.ObjectLink", OleDbType.VarChar, 100).Value = O_ObjectLink.Text
Command.Parameters.Add("@dotnet.itags.org.Comment", OleDbType.VarChar, 100).Value = O_Comment.Text
Command.Parameters.Add("@dotnet.itags.org.MaxSceneCount", OleDbType.Integer, 4).Value = O_MaxSceneCount.Text

Try
Command.Connection.Open()
Command.ExecuteNonQuery() 'save record

Catch ex As Exception
Response.Write("Exception:")
Response.Write(ex.ToString)
End Try

Command.Connection.Close()
End Sub

The error is associated with a call to System.Number.ParseInt32(). That tells me that one of the parameters is expected to contain an integer or a string representation of an integer but does not. Identify integer parameters. Then in the debugger, determine if any of them are:
1. Not assigned. If a string is provided, is it an empty string?
2. Contains other characters than digits?
These two cases will generate that exception. (The .net docs for Convert.ToInt32 say FormatException will occur when:value does not consist of an optional sign followed by a sequence of digits (zero through nine).)

System.FormatException: Input string was not in a correct format....?

I've been working on this for a while, googled and everything, and i still can't work out what is wrong with this string... I keep getting this error:

System.FormatException: Input string was not in a correct format


public void btnCalculate_Click(object sender, System.EventArgs e)
{
double Label = Convert.ToDouble((Convert.ToInt32(lblQrtrs.Text)) + (Convert.ToInt32(lblOnes.Text)) + (Convert.ToInt32(lblTwos.Text)) + (Convert.ToInt32(lblFives.Text)) + (Convert.ToInt32(lblTens.Text)) + (Convert.ToInt32(lblTwenties.Text)) + (Convert.ToInt32(lblFifties.Text)) + (Convert.ToInt32(lblHundreds.Text)));
lblCalculate.Text = string.Format("{0:c}", Label);

Can anybody tell what i'm doing wrong here? Thanks,
Austin W.I should specify that each of those labels was already converted into a currency format from a textbox, like:


double Label = Convert.ToDouble(Convert.ToInt32(tbHundreds.Text) * 100);
lblHundreds.Text = string.Format("{0:c}", Label);

Just an update...

Ive converted my code to this...Its still not working but i feel like its on a better track than it was before, anybody got any ideas?


double Qrtrs = Convert.ToDouble(lblQrtrs.Text);
double Ones = Convert.ToDouble(lblOnes.Text);
double Twos = Convert.ToDouble(lblTwos.Text);
double Fives = Convert.ToDouble(lblFives.Text);
double Tens = Convert.ToDouble(lblTens.Text);
double Twenties = Convert.ToDouble(lblTwenties.Text);
double Fifties = Convert.ToDouble(lblFifties.Text);
double Hundreds = Convert.ToDouble(lblHundreds.Text);

double Label = (Qrtrs + Ones + Twos + Fives + Tens + Twenties + Fifties + Hundreds);
lblCalculate.Text = string.Format("{0:c}", Label);


Hi,
I am having the same problem, 'input string was not in a correctformat' when I try to convert something to double usingConvert.ToDouble(). I have a text box and if I enter something likethis, 123.45 and click on the submit button I get this error. Any help.
Thanks.


I think I got your answer. Now first I dontknow whats the string of your Label. Let's say that the label has"23.45" okay and you try to do the following:
string someString = Label1.Text;
int someInt = Int32.Parse(someString); // This will give error
It will give error since it was not able to parse the string as Int32. If you try to parse it as Double than it will run okay.
string someString = "23.45";
Double myDouble = Double.Parse(someString); // This will work fine.
Now if your lblhundred contains "100" without any decimal points than you can simply do this and it will work.
string someString = "455";
int someInt = Int32.Parse(someString);
Hope this will help!

Also check using the WebControl Type "Label" as a variable, like maybe change these two lines to:

double LabelValue = (Qrtrs + Ones + Twos + Fives + Tens + Twenties + Fifties + Hundreds);
lblCalculate.Text = string.Format("{0:c}", LabelValue);
NC...

Wednesday, March 28, 2012

System.IO?

If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:

<%@dotnet.itags.org. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")

lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>

if I get rid of the <%@dotnet.itags.org. Import....%line, then ASP.NET generates the
following error:

Type 'FileInfo' is not defined.

pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).

Why?

Please correct me if I am wrong.

Thanks,

Arpanre:

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces
that get imported in all ASP.NET page automatically


You are wrong.

If you wish to use System.IO, you must import it explicitly.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:
>
<%@. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>
lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>
>
if I get rid of the <%@. Import....%line, then ASP.NET generates the
following error:
>
Type 'FileInfo' is not defined.
>
pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).
>
Why?
>
Please correct me if I am wrong.
>
Thanks,
>
Arpan
>


Thanks Juan for pointing out my mistake. Actually the ASP.NET book I am
referring to learn ASP.NET states that System.IO is one of the seven
namespaces that get imported automatically by all ASP.NET pages - the
remaining 6 being

System
System.Collections
System.Web
System.Web.UI
System.Web.UI.HtmlControls
System.Web.UI.WebControls

I hope the above 6 namespaces "do" get imported automatically by all
ASP.NET pages. If not, then please let me know. God knows what all I
must have learnt wrong from that ASP.NET book!

BTW, are there any additional namespaces apart from the above 6 that
all ASP.NET pages import automatically?

Thanks once again,

Regards,

Arpan

Juan T. Llibre wrote:

Quote:

Originally Posted by

re:

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces
that get imported in all ASP.NET page automatically


>
You are wrong.
>
If you wish to use System.IO, you must import it explicitly.
>
>
>
>
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:

<%@. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")

lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>

if I get rid of the <%@. Import....%line, then ASP.NET generates the
following error:

Type 'FileInfo' is not defined.

pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).

Why?

Please correct me if I am wrong.

Thanks,

Arpan


Arpan,
If you do not see it in the using .. list (or "Import" in VB.NET) when you
create a class or web page, then you need to explicitly add it an ensure that
the project has a reference to the namespace assembly. If it isn't there, you
will find out about it very quickly!
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Arpan" wrote:

Quote:

Originally Posted by

Thanks Juan for pointing out my mistake. Actually the ASP.NET book I am
referring to learn ASP.NET states that System.IO is one of the seven
namespaces that get imported automatically by all ASP.NET pages - the
remaining 6 being
>
System
System.Collections
System.Web
System.Web.UI
System.Web.UI.HtmlControls
System.Web.UI.WebControls
>
I hope the above 6 namespaces "do" get imported automatically by all
ASP.NET pages. If not, then please let me know. God knows what all I
must have learnt wrong from that ASP.NET book!
>
BTW, are there any additional namespaces apart from the above 6 that
all ASP.NET pages import automatically?
>
Thanks once again,
>
Regards,
>
Arpan
>
>
Juan T. Llibre wrote:

Quote:

Originally Posted by

re:

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces
that get imported in all ASP.NET page automatically


You are wrong.

If you wish to use System.IO, you must import it explicitly.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:
>
<%@. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>
lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>
>
if I get rid of the <%@. Import....%line, then ASP.NET generates the
following error:
>
Type 'FileInfo' is not defined.
>
pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).
>
Why?
>
Please correct me if I am wrong.
>
Thanks,
>
Arpan
>


>
>


In ASP.NET 2.0, you can control which namespaces are
imported automatically by configuring them in web.config.

Any namespace you define in web.config will be automatically imported,
and you will not have to import it specifically.

See :
http://msdn2.microsoft.com/en-us/li...collection.aspx
and
http://msdn2.microsoft.com/en-us/li...gessection.aspx
re:

Quote:

Originally Posted by

I hope the above 6 namespaces "do" get imported automatically by all ASP.NET pages.
If not, then please let me know.
BTW, are there any additional namespaces apart from the above 6 that
all ASP.NET pages import automatically?


In ASP.NET 2.0, the default namespaces are defined in the default web.config, located in :
Drive:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ CONFIG

Here they are :

<pages>
<namespaces>
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
</pages>

You could add System.IO, so it's automatically imported, by adding :

<add namespace="System.IO" />

to the <namespacessection of web.config.

Of course, any other namespace you want to import automatically can also be added.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156710516.410124.90070@.m79g2000cwm.googlegro ups.com...
Thanks Juan for pointing out my mistake. Actually the ASP.NET book I am
referring to learn ASP.NET states that System.IO is one of the seven
namespaces that get imported automatically by all ASP.NET pages - the
remaining 6 being

System
System.Collections
System.Web
System.Web.UI
System.Web.UI.HtmlControls
System.Web.UI.WebControls

I hope the above 6 namespaces "do" get imported automatically by all
ASP.NET pages. If not, then please let me know. God knows what all I
must have learnt wrong from that ASP.NET book!

BTW, are there any additional namespaces apart from the above 6 that
all ASP.NET pages import automatically?

Thanks once again,

Regards,

Arpan

Juan T. Llibre wrote:

Quote:

Originally Posted by

re:

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces
that get imported in all ASP.NET page automatically


>
You are wrong.
>
If you wish to use System.IO, you must import it explicitly.
>
>
>
>
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:

<%@. Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")

lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>

if I get rid of the <%@. Import....%line, then ASP.NET generates the
following error:

Type 'FileInfo' is not defined.

pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).

Why?

Please correct me if I am wrong.

Thanks,

Arpan


"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

Please correct me if I am wrong.


You are wrong.
Thanks all of you for your helpful inputs.

Regards,

Arpan

Mark Rae wrote:

Quote:

Originally Posted by

"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...
>

Quote:

Originally Posted by

Please correct me if I am wrong.


>
You are wrong.


Juan T. Llibre wrote:

Quote:

Originally Posted by

re:

Quote:

Originally Posted by

>If I am not wrong, System.IO is one of the seven namespaces
>that get imported in all ASP.NET page automatically


>
You are wrong.
>
If you wish to use System.IO, you must import it explicitly.
>
>
>
>
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Arpan" <arpan_de@.hotmail.comwrote in message
news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

>If I am not wrong, System.IO is one of the seven namespaces that get
>imported in all ASP.NET page automatically but in the following code:
>>
><%@. Import Namespace="System.IO" %>
><script runat="server">
> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
> Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>>
> lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
> lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
> lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
>& "<br>"
> lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
>"<br>"
> lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
> End Sub
></script>
><form runat="server">
><asp:Label ID="lblOutput" runat="server">
></form>
>>
>if I get rid of the <%@. Import....%line, then ASP.NET generates the
>following error:
>>
>Type 'FileInfo' is not defined.
>>
>pointing to the very first line within the Page_Load sub (Dim
>ioFileInfo As New FileInfo...).
>>
>Why?
>>
>Please correct me if I am wrong.
>>
>Thanks,
>>
>Arpan
>>


>
>


Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the
compilation section to see the default imports (there are nine).

For 1.1 look in <framework dir>\v1.1.4322\CONFIG\machine.config. There
are eight listed there. The new one in 2.0 is System.Configuration.

Kevin Jones
re:

Quote:

Originally Posted by

Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the compilation section to see
the default imports (there are nine).


Kevin,

don't you consider mscorlib to be one of them ?

<add assembly="mscorlib" />

Also, doesn't the vbc compiler automatically import Microsoft.VisualBasic ?

Also, isn't the list supplied in the default web.config's pages element accurate ?

<pages>
<namespaces>
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
</pages>

Won't any namespace defined in web.config be automatically imported,
and you will not have to import it specifically ?

See :
http://msdn2.microsoft.com/en-us/li...collection.aspx
and
http://msdn2.microsoft.com/en-us/li...gessection.aspx
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Kevin Jones" <kjonesNOSPAM@.develop.comwrote in message
news:O6w44soyGHA.1252@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Juan T. Llibre wrote:

Quote:

Originally Posted by

>re:

Quote:

Originally Posted by

>>If I am not wrong, System.IO is one of the seven namespaces
>>that get imported in all ASP.NET page automatically


>>
>You are wrong.
>>
>If you wish to use System.IO, you must import it explicitly.
>>
>>
>>
>>
>Juan T. Llibre, asp.net MVP
>aspnetfaq.com : http://www.aspnetfaq.com/
>asp.net faq : http://asp.net.do/faq/
>foros de asp.net, en espaol : http://asp.net.do/foros/
>===================================
>"Arpan" <arpan_de@.hotmail.comwrote in message
>news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

>>If I am not wrong, System.IO is one of the seven namespaces that get
>>imported in all ASP.NET page automatically but in the following code:
>>>
>><%@. Import Namespace="System.IO" %>
>><script runat="server">
>> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
>> Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>>>
>> lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
>> lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
>> lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
>>& "<br>"
>> lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
>>"<br>"
>> lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
>> End Sub
>></script>
>><form runat="server">
>><asp:Label ID="lblOutput" runat="server">
>></form>
>>>
>>if I get rid of the <%@. Import....%line, then ASP.NET generates the
>>following error:
>>>
>>Type 'FileInfo' is not defined.
>>>
>>pointing to the very first line within the Page_Load sub (Dim
>>ioFileInfo As New FileInfo...).
>>>
>>Why?
>>>
>>Please correct me if I am wrong.
>>>
>>Thanks,
>>>
>>Arpan
>>>


>>
>>


Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the compilation section to see
the default imports (there are nine).
>
For 1.1 look in <framework dir>\v1.1.4322\CONFIG\machine.config. There are eight listed there. The
new one in 2.0 is System.Configuration.
>
Kevin Jones


don't you consider mscorlib to be one of them ?

Quote:

Originally Posted by

>
<add assembly="mscorlib" />


Oops, yep of course.

Quote:

Originally Posted by

Also, doesn't the vbc compiler automatically import


Microsoft.VisualBasic ?

Ah! I don't do VB, so I didn't look :)

Quote:

Originally Posted by

Also, isn't the list supplied in the default web.config's pages


element accurate ?

Quote:

Originally Posted by

>
<pages>
<namespaces>
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
</pages>


Yep, but I was listing the assemblies not the namespaces, which of
course I should have been.

Quote:

Originally Posted by

Won't any namespace defined in web.config be automatically imported,
and you will not have to import it specifically ?
>
See :
>


http://msdn2.microsoft.com/en-us/li...collection.aspx

Quote:

Originally Posted by

and
>


http://msdn2.microsoft.com/en-us/li...gessection.aspx

Quote:

Originally Posted by

>


Juan T. Llibre wrote:

Quote:

Originally Posted by

re:

Quote:

Originally Posted by

>Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the compilation section to see
>the default imports (there are nine).


>
Kevin,
>
>
>
>
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Kevin Jones" <kjonesNOSPAM@.develop.comwrote in message
news:O6w44soyGHA.1252@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

>Juan T. Llibre wrote:

Quote:

Originally Posted by

>>re:
>>>If I am not wrong, System.IO is one of the seven namespaces
>>>that get imported in all ASP.NET page automatically
>>You are wrong.
>>>
>>If you wish to use System.IO, you must import it explicitly.
>>>
>>>
>>>
>>>
>>Juan T. Llibre, asp.net MVP
>>aspnetfaq.com : http://www.aspnetfaq.com/
>>asp.net faq : http://asp.net.do/faq/
>>foros de asp.net, en espaol : http://asp.net.do/foros/
>>===================================
>>"Arpan" <arpan_de@.hotmail.comwrote in message
>>news:1156708999.220650.277560@.m79g2000cwm.googlegr oups.com...
>>>If I am not wrong, System.IO is one of the seven namespaces that get
>>>imported in all ASP.NET page automatically but in the following code:
>>>>
>>><%@. Import Namespace="System.IO" %>
>>><script runat="server">
>>> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
>>> Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
>>>>
>>> lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
>>> lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
>>> lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
>>>& "<br>"
>>> lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
>>>"<br>"
>>> lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
>>> End Sub
>>></script>
>>><form runat="server">
>>><asp:Label ID="lblOutput" runat="server">
>>></form>
>>>>
>>>if I get rid of the <%@. Import....%line, then ASP.NET generates the
>>>following error:
>>>>
>>>Type 'FileInfo' is not defined.
>>>>
>>>pointing to the very first line within the Page_Load sub (Dim
>>>ioFileInfo As New FileInfo...).
>>>>
>>>Why?
>>>>
>>>Please correct me if I am wrong.
>>>>
>>>Thanks,
>>>>
>>>Arpan
>>>>
>>>


>Look in <framework dir>\v2.0.50727\CONFIG\web.config.comments under the compilation section to see
>the default imports (there are nine).
>>
>For 1.1 look in <framework dir>\v1.1.4322\CONFIG\machine.config. There are eight listed there. The
>new one in 2.0 is System.Configuration.
>>
>Kevin Jones


>
>