Visual Studio Preview Data shows no data RRS feed

  • Question

  • I am using a dataset in vs. I have several datatables, which are working fine. And had decided to add a new one. I added it and ran the sql query in the query builder in vs and it ran fine returning data. However it was not returning data in my web page. So I tried running the "Preview Data" tool within vs and it also returns no data there and no error either (its just empty). Here's the code:

    SELECT DISTINCT c.Computer_Idn, c.DeviceName, c.LoginName, c.FullName, osu.UpdateName, osu.Publisher, osu.InstallDate
    FROM         dbo.OSUpdates AS osu INNER JOIN
                          dbo.Computer AS c ON osu.Computer_Idn = c.Computer_Idn
    WHERE     (osu.UpdateName LIKE @Patch)
    Thursday, December 10, 2009 2:01 PM

All replies

  • Are you supplying value for the parameter?
    Can you please post the code that calls the sql syntax?


    Thursday, December 10, 2009 2:55 PM
  • Thanks for the reply. Yes I am supplying the parameter. The Preview Data tool could not run the query without it. Also in this case the code calling the sql does not actually matter, because the Preview Data tool from vs does not return data either. In other words the issue is happening within the dataset/dataadapter--not anything from .net code on my pages. I hope this clarifies my situation. Thanks.
    Thursday, December 10, 2009 3:00 PM
  • is your dataset/dataadapter strongly typed or untyped?
    Thursday, December 10, 2009 3:18 PM
  • I am building it from the vs gui. So its is strongly typed. In other words when I view the properties of my datatable columns from vs I can see that they each have an appropriate type assigned to them. I have not modified any of the xsd and related dataset files that vs auto generated for me. And like I said I have several other datatables that I created previously in similar fashion that are working fine. All datatables are querying from the same db.
    Thursday, December 10, 2009 3:21 PM

  • So When your form loads do you have a code that's executing your query something like this

            Dim PatchNum As Integer = 12345
            Me.ComputerTableAdapter.FillByPatchNum(Me.ComputersDataSet.Computers, PatchNum)

    Thursday, December 10, 2009 4:04 PM
  • I have code that obviously gets called and is returning nothing. But as I stated before I too also thought it was something in my calling forms code that was failing. However, and perhaps you're not following because you never used the Preview Data tool on visual studio, but the Preview Data tool is also returning nothing. So logically it seems that the failure to retrieve data is occuring before my form code has a chance to run. Again there are no errors, it just returns empty.

    However when I run the query, again from within visual studio's query builder, I do get valid data returned. So I guess my question to you is are we talking about the same thing, because it appears that you have either not used or are not talking about the dataset generator within visual studio, which is precisely what I am using and having problems with. I thought that was obvious, but if it was not I apologize. Thanks for your help.

    Thursday, December 10, 2009 4:22 PM
  • Gotcha! 
    Most of my work is done in code I hardly use the dataset designer I use it in my code, I've worked with the designer in the past so I know what you're talking about when you refer to the designer that your query is returning data in the designer but once you preview the data inside the designer you get no results.

    have you tried to take out the parameter and preview the data without the parameter. if you are able to preview the data that means your bug is in the parameter. 

    Let us know

    Thursday, December 10, 2009 5:01 PM
  • Ok now we're getting somewhere. Yes I was thinking along the same lines as I've had issues in the past with parameters. Basically there seems to be some kind of typing or conversion issue, which is weird because in this case the parameter is text and not some odd number type. I've taken your advise, thank you very much, and yes without a parameter it returns correctly.

    Now the parameter type is an AnsiString. I am also using other datatables with an AnsiString parameter and those definitely work. So we're a little warmer, but do you have any other ideas?
    Thursday, December 10, 2009 5:25 PM
  • I see that you are using the Like operator in your Parameter try to use Equal instead just for debugging purpose.
    Thursday, December 10, 2009 5:55 PM
  • Yeah, I already tried that previously. But it did not help, actually my query stopped working as it was originally expecting a variable string for matching purposes.
    Thursday, December 10, 2009 6:02 PM

  • I think the problem is with your Where clause syntax on the Like Operator

    Construct your where clause similar to the code below
    WHERE        (ContactTitle LIKE '%' + @ContactTile + '%')

    Thursday, December 10, 2009 6:05 PM
  • Thanks for all you're help. I also tried that and no difference. And I do not need to do that for my other datatable queries so ...
    Thursday, December 10, 2009 6:06 PM
  • Hey John do u have yahoo messenger? Do u have time to chat?
    Thursday, December 10, 2009 6:07 PM
  • No I don't but I can with
    Thursday, December 10, 2009 7:07 PM
  • Hello,

    How is problem now?  Could you please provide us with more detailed information? 

    Best Regards,
    Lingzhi Sun

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, December 14, 2009 10:07 AM
  • Nothings changed problem still exists.
    Monday, December 14, 2009 7:26 PM
  • Nothings changed problem still exists.

    So your query is not working? are you getting any error?
    Monday, December 14, 2009 7:39 PM
  • No like I said last time we were closer, but not there yet. No errors for whatever reason it does not like the parameter given. I don't get why since my other queries/datatables are fine.
    Monday, December 14, 2009 9:09 PM
  • Can you try to create a new datatable that's using the same query with the Like operator. I'm wondering maybe something else is causing the query interruption.
    if it still not working on a new datatable create a fresh dataset and let's see if it will work with a fresh dataset

    WHERE        (ContactTitle LIKE '%' + @ContactTile + '%')

    Monday, December 14, 2009 9:16 PM
  • The syntax you gave previously and I've tried. Also I've tried recreating the datatable twice now and still no go. Right now I have no idea. Its auto generated and I'm not intervening or changing any generated code. I also tried switching from like to = and then back again and that did not work either.
    Thursday, December 17, 2009 3:02 AM
  • I don't know I've tested it on my end and it works. Strange!!

    Have you tried it on a fresh new project?

    Thursday, December 17, 2009 10:59 AM
  • Case-sensitivity maybe?
    ~~Bonnie Berent [C# MVP]
    Sunday, December 20, 2009 1:02 AM
  • Nope tried that too
    Thursday, January 14, 2010 1:14 PM