Showing posts with label block. Show all posts
Showing posts with label block. Show all posts

Wednesday, March 28, 2012

System.IO.File.Copy not copying and no error

I'd suggest wrapping the copy in a Try/Catch block just to be sure. Then
throw a new exception, outputing your source/destination paths along with
the original exception:

Try
System.IO.File.Copy(Source,Dest)
Catch ex as exception
throw new Exception("Source: '" & source & "' - Dest: '" & dest &
"'",ex)
end try

also, put a break point at the Throw, and examine your variables.

"Xander Q." <xander_q@dotnet.itags.org.hotmail.com> wrote in message
news:1958ff15.0307052341.260d3083@dotnet.itags.org.posting.google.c om...
> Something really strange is happening. i'm using the following code to
> copy a file. this worked on my development machine, but when i moved
> it to the server (win2k) it is not copying the file and not generating
> an error. it just merrily goes on.
> ---------------------
> source= Server.MapPath("/TTClaimsForm2/Reports/xxx.doc")
> dest= Server.MapPath("/TTClaimsForm2/Reports/Temp/xxx.doc")
> System.IO.File.Copy(source, dest)
> ---------------------
>
> i checked the value of dest and it's correct. i replaced it with an
> empty string and it gave an error as expected.
> BUT i noticed that if i hard code destination like this:
> System.IO.File.Copy(source,
> "C:\inetpub\wwwroot\ttclaimsform2\Temp\xxx.doc") then the copy works.
> how can this be happening?"David Waz..." <dlw@.pickpro.com> wrote in message news:<bhZNa.1682$Ro2.1449@.newssvr31.news.prodigy.com>...
> I'd suggest wrapping the copy in a Try/Catch block just to be sure. Then
> throw a new exception, outputing your source/destination paths along with
> the original exception:

ah yes i neglected to mention that i already did that, and the value
of 'dest' is correct. it is the same as the hard-coded string and yet
it fails...

damn i hate this stuff!!!

but thx for the input...

Thursday, March 22, 2012

System.NullReferenceException: Object variable or With block variable not set

Please help i am getting the following error:
System.NullReferenceException: Object variable or With block variable not set

on this line.


TextBox1.Text = Trim(Row.Item("eng_lbl"))

I am trying to display the values of a record from the table in 4 text box fields.
I am new to asp.net. Please kindly help.


Dim mydataset As New DataSet
Dim myadapter As New SqlDataAdapter
Dim strId As String = Request.QueryString("lbl_Id")
Dim Row

Dim myCommand As New SqlClient.SqlCommand

Dim sql As String = "select * from tbl_labels where id =" & CInt(strId)

If Not Page.IsPostBack Then
MyCommand = New SqlCommand(sql, MyConnection)

myadapter = New SqlDataAdapter(myCommand)

mydataset.Clear()
myadapter.Fill(mydataset)

If mydataset.Tables(0).Rows.Count > 0 Then
TextBox1.Text = Trim(Row.Item("eng_lbl"))
TextBox2.Text = Trim(Row.Item("esp_lbl"))
TextBox3.Text = Trim(Row.Item("fr_lbl"))
TextBox4.Text = Trim(Row.Item("ger_lbl"))
End If
End If

You're not assign row to anything..

I.E.


Dim Row As DataRow

If mydataset.Tables(0).Rows.Count > 0 Then

Row = mydataset.Tables(0).Rows(0)

TextBox1.Text = Trim(Row.Item("eng_lbl"))

TextBox2.Text = Trim(Row.Item("esp_lbl"))

TextBox3.Text = Trim(Row.Item("fr_lbl"))

TextBox4.Text = Trim(Row.Item("ger_lbl"))

End If

System.NullReferenceException: Object variable or With block varia

Hello -

I don't know if it's possible or not, but I am trying to bind data from a
Sql Server DB to the header in a datalist. I received the above error
message.

First, is it possible to bind data from a DB to the header and if so, what
could be causing the error message?

Alternatively, can you only put text in the header of a datalist?
--
SandySandy,
You didn't provide any code many it very difficult to imagine what the error
is...

Yyou can't bind data to a header in the typical databinding sense.
Information is bound row-by-row to the individual items...There's no row
assigned to the header...you can set values of the header progamatically
however...

myGrid.Columns(0).HeaderText =
myDataSet.Tables(0).Rows(0)("Blah").ToString()

or something similar...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Sandy" <Sandy@.discussions.microsoft.com> wrote in message
news:BBD0DEED-455D-473C-8D00-8D969825BCF6@.microsoft.com...
> Hello -
> I don't know if it's possible or not, but I am trying to bind data from a
> Sql Server DB to the header in a datalist. I received the above error
> message.
> First, is it possible to bind data from a DB to the header and if so, what
> could be causing the error message?
> Alternatively, can you only put text in the header of a datalist?
> --
> Sandy
Thanks, Karl!

"Karl Seguin" wrote:

> Sandy,
> You didn't provide any code many it very difficult to imagine what the error
> is...
> Yyou can't bind data to a header in the typical databinding sense.
> Information is bound row-by-row to the individual items...There's no row
> assigned to the header...you can set values of the header progamatically
> however...
> myGrid.Columns(0).HeaderText =
> myDataSet.Tables(0).Rows(0)("Blah").ToString()
> or something similar...
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is
> annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
> "Sandy" <Sandy@.discussions.microsoft.com> wrote in message
> news:BBD0DEED-455D-473C-8D00-8D969825BCF6@.microsoft.com...
> > Hello -
> > I don't know if it's possible or not, but I am trying to bind data from a
> > Sql Server DB to the header in a datalist. I received the above error
> > message.
> > First, is it possible to bind data from a DB to the header and if so, what
> > could be causing the error message?
> > Alternatively, can you only put text in the header of a datalist?
> > --
> > Sandy
>

System.NullReferenceException: Object variable or With block varia

Hello -
I don't know if it's possible or not, but I am trying to bind data from a
Sql Server DB to the header in a datalist. I received the above error
message.
First, is it possible to bind data from a DB to the header and if so, what
could be causing the error message?
Alternatively, can you only put text in the header of a datalist?
--
SandySandy,
You didn't provide any code many it very difficult to imagine what the error
is...
Yyou can't bind data to a header in the typical databinding sense.
Information is bound row-by-row to the individual items...There's no row
assigned to the header...you can set values of the header progamatically
however...
myGrid.Columns(0).HeaderText =
myDataSet.Tables(0).Rows(0)("Blah").ToString()
or something similar...
Karl
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Sandy" <Sandy@.discussions.microsoft.com> wrote in message
news:BBD0DEED-455D-473C-8D00-8D969825BCF6@.microsoft.com...
> Hello -
> I don't know if it's possible or not, but I am trying to bind data from a
> Sql Server DB to the header in a datalist. I received the above error
> message.
> First, is it possible to bind data from a DB to the header and if so, what
> could be causing the error message?
> Alternatively, can you only put text in the header of a datalist?
> --
> Sandy