?
Solved

There is no row at positon 0?!

Posted on 2009-05-01
11
Medium Priority
?
198 Views
Last Modified: 2012-08-14
Hi there,

Language: vb.net
SQL: SQL CE

I seem to have this problem where when i open a form which runs a parameterised query via Form1.show then it works find but when i open the form as a NEW form by using

 dim newform as New Form1
newform.show()

i get an error saying there is no row at position 0?

can any please help

thanks

baz
0
Comment
Question by:baz86
  • 5
  • 3
  • 3
11 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 24283243
can you post more code
0
 

Author Comment

by:baz86
ID: 24283286
Hi erikTsomik, thanks for the prompt response....the code on form 2 is as follows:
Dim ConnStr As String = "Data Source=\My Documents\ECADDY.sdf"
    Dim conn As New SqlCeConnection
    Dim ds As New DataSet
    Dim da As SqlCeDataAdapter
----------------------------
conn.ConnectionString = ConnStr
        conn.Open()
 
Dim sql As String = "SELECT CustomerPic From tblCustomer Where CustomerID = '" & Form2.Label5.Text & "' AND CompanyID = 3"
            da = New SqlCeDataAdapter(sql, conn)
            da.Fill(ds, "CustPics")
            Dim currentimage As String
            Dim image As String
 
            currentimage = ds.Tables("CustPics").Rows(0).Item(0)
image = ("" + currentimage + "")
            Dim bitmap As New Bitmap(image)
 
            
            pbCustPicBox.Image = bitmap
            pbCustPicBox.Size = bitmap.Size

Open in new window

0
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24283467
Debug the code and check if you have data in dataset.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:erikTsomik
ID: 24283496
output the query
0
 

Author Comment

by:baz86
ID: 24283513
what i don'd quiet understand is when i open a 'New' Form2...i get the error but if i just use form2.show() then its fine but then obviously if i want to start again, i will need to use the New method.......
i just don't see how calling on the New method can be the difference ..
 
erikTsomik, the output from the query is just a string which denotes where the picture for that customer is held on the computer.....i then put that in quotations so that i can use it for the picturebox, bitmap properties
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 24283531
because may be there is no image to inserted there
0
 

Author Comment

by:baz86
ID: 24283539
the images are there on the pc and also the locations of the images are stored in the database....i check this everytime
0
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24283561
Is this  Form2.Label5.Text value given at run time or design time?

Check the  Form2.Label5.Text value
0
 

Author Comment

by:baz86
ID: 24283603

srikanthreddyn143,
the value of label5.text is actually passed from form1...it was just a mistake on my behalf when i pasted the code in......how can i get the form1.label5.text value to be sent to the query because i set a breakpoint on the query posted above and when form2 is opened as a new form, label5.text returns blank.....how can i rectify this?
0
 
LVL 11

Accepted Solution

by:
srikanthreddyn143 earned 2000 total points
ID: 24283640
It is a sample look into it
--Code in Form1--
Dim f2 As New Form2
      f2.Init(LblText.text)
        f2.Show()
 
 
--Form2--
Public Class Form2
    Dim il As String
    Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
    End Sub
 
    Public Sub Init(ByVal s As String)
        il = s
    End Sub
End Class

Open in new window

0
 

Author Comment

by:baz86
ID: 24284147
BRILLIANT!...that worked perfect!! Thank you so much
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question