简体   繁体   中英

iterating through the rows of a table using tableadapters in vb.net

i have a problem. I have database with a tableadpater. i want to get the userid with this tableadapter.

 Dim dsGN As New ForumTableAdapters.Message2TableAdapter

    Dim dtBetrieb As Data.DataTable = dsGN.GetUserIdFromThisMessage(ConversationID)

    For Each objRow As dsGN.Message2Row In dtBetrieb.Rows

        mystring = objRow.UserId.ToString
    Next

i get the error "dsGN.Message2Row is not defined"

The Name ob my table in the database is "Message" i hope that somebody can help me.

You have to do this :

GridView.DataSource = yourAdapter.GetUserID(ID);
GridView.DataBind();

Then make a tableadapter named:GetUserID where you select from your tables passing the ID like: @ID;

Hope this helped! You can read more about this here:

http://msdn.microsoft.com/en-us/library/aa581776.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM