How to convert this

Discussion in 'C#' started by lieweffect, Jun 3, 2006.

  1. lieweffect

    lieweffect New Member

    Joined:
    Apr 20, 2006
    Messages:
    58
    Likes Received:
    0
    Trophy Points:
    0
    Can any c# programmer expert help me to convert this vb.net code to c# code

    Dim MyItem = ListViewBookRecord.Items.Add(dr("ID".ToString))
    With MyItem
    .SubItems.Add(dr("bookname".ToString))
    .SubItems.Add(dr("authorname".ToString))
    .SubItems.Add(dr("booktype".ToString))
    .SubItems.Add(dr("price".ToString))

    End With


    Dim SaveOrEdit As String = ""
    Dim Apppath = Application.StartupPath
    Dim DatabasePath = Apppath & "\..\bookrecord.mdb;"
    Dim ConnString As String = _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & DatabasePath & _
    "Persist Security Info=False"
     
    Last edited: Jun 3, 2006
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I am not sure what is ListViewBookRecord but the C# code would be like
    Code:
    ReturnTypeOfAddMethod MyItem = ListViewBookRecord.Items.Add(dr("ID".ToString))
    MyItem.SubItems.Add(dr("bookname".ToString))
    MyItem.SubItems.Add(dr("authorname".ToString))
    MyItem.SubItems.Add(dr("booktype".ToString))
    MyItem.SubItems.Add(dr("price".ToString))
     
  3. lieweffect

    lieweffect New Member

    Joined:
    Apr 20, 2006
    Messages:
    58
    Likes Received:
    0
    Trophy Points:
    0
    It give me the error:
    "The type or namespace name 'ReturnTypeOfAddMethod' could not be found (are you missing a using directive or an assembly reference?)"
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I mentioned the reason for the above error also.
    Also I used the name of the variable also very self explanatory but then also I will repeat that its a variable of the return type of your add member.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice