none
'SqlDbType' is not a member of 'Data'. RRS feed

  • Question

  • I have vs 2012  project which i am using more than 7 years

    cmd4.Parameters.Add("@username", Data.SqlDbType.Char, 10).Value = luid

    But now i am getting below error. see the error page

    second image

    May be its happen with framework 4.5 when i upload new folder in server but i want to keep run all this old things on the iis server. 

    What i need to do on server so that all things work properly?

    so what is the solution?

    thanks




    Saturday, March 28, 2020 9:20 AM

Answers

All replies

  • Hello,

    The following appears to be the issue which I screen grabbed from your screenshot. Seems whatever you did in regards to Framework 4.5 is the root issue. Did you rebuild the project after moving to 4.5 ?

    This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to Visual Basic 2012, which is no longer the latest


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by AnkitKumar2016 Saturday, March 28, 2020 10:06 AM
    • Unmarked as answer by AnkitKumar2016 Saturday, March 28, 2020 10:06 AM
    Saturday, March 28, 2020 9:45 AM
    Moderator
  • Thanks for reply. 

    But i don't want  upgrade. We still working with 4.0. And i undo my changes of 4.5 but still coming error.

    so how i will resolve this. I have morethan 400+ pages. 

    I want its work 

    Data.SqlDbType.Char

    instead of

    System.Data.SqlDbType.Char

    I think issue coming with name space.

    Also when I am building then getting same error 

    "SqlDbType' is not a member of 'Data'"

    my code is 

    cmd4.Parameters.Add("@username", Data.SqlDbType.Char, 10).Value = luid

    pls provide need full solution?



    Saturday, March 28, 2020 10:09 AM
  • In regards to "pls provide need full solution"

    Remove "Data"

    using System.Data;
    using System.Data.SqlClient;
    
    namespace SqlServerCodeSamples
    {
        public class Example
        {
            private void Demo()
            {
                using (var cn = new SqlConnection(""))
                {
                    using (var cmd = new SqlCommand() {Connection = cn})
                    {
                        cmd.Parameters.Add("@username", SqlDbType.Char, 10).Value = "";
                    }
    
                }
            }
        }
    }

    Note, no errors.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Saturday, March 28, 2020 11:25 AM
    Moderator
  • Yea about 16 years ago they said it would become obsolete because this code was somehow ambigious. 

    They made from it

    cmd4.Parameters.AddwithValue("@username",luid)

    I don't know if the at least did it, but this is much easier anyway. 


    Success
    Cor

    Saturday, March 28, 2020 1:00 PM
  • Thanks for reply....

    But this two days ago... this was working

    cmd4.Parameters.Add("@username", Data.SqlDbType.Char, 10).Value = luid

    can i do anything in web.Config for support this old? Because I have 400+ pages and difficult to track-out because here is lock-down and can go the office.

    Any trick or smart way to sort out the issue?

    Thanks


    Saturday, March 28, 2020 1:17 PM
  • What I would do is first backup the project in your source control e.g. TFS, GitHub repo.

    Next open the solution/project in Visual Studio, do a search/replace e.g.

    Search for Data.SqlDbType and replace with SqlDbType. You can do a replace all or incremental replace, the replace all is risky as you may replace something that is not related to the parameter issue but that is why we use source control, to rollback if needed while doing a search and replace manually sure that is a lot of mouse clicks but what else are you doing with your time and it's safer.

    Here is a thought, do one change, compile, you should have one less error then before, this tells you it's working or not.

    Build the solution. You may have compile errors which may be that a using statement is needed for 

    using System.Data;

    Bottom line is there are no shortcuts as the issue is outside of code, you need to adapt to that change.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Saturday, March 28, 2020 2:11 PM
    Moderator
  • In order to investigate what Data is, try selecting this word, then press <F12>. Does it show a thing that is called “Data”?

    Saturday, March 28, 2020 6:19 PM
  • "Data" is => System.Data

    previously working with only "Data" but now getting error without "system.Data"

    Sunday, March 29, 2020 1:37 PM
  • "Data" is => System.Data

    previously working with only "Data" but now getting error without "system.Data"


    As I mentioned before, the easiest way to fix this is to do a search and replace or spend a good deal of time trying to figure out what changed and what changed is nothing we can examine. 


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Sunday, March 29, 2020 1:43 PM
    Moderator


  • can i do anything in web.Config 


    Did you already ask this question in the https://forums.asp.net

    Success
    Cor

    Sunday, March 29, 2020 2:34 PM
  • I can write following code in vb.net

    Data.
    Linq.
    

    but in c# ... I can not write in this way.

    I have page of vb.net. But now not supporting why?

    pls read care fully my question

    thanks

    Sunday, March 29, 2020 2:39 PM