By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,239 Members | 1,505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,239 IT Pros & Developers. It's quick & easy.

how to display data into a message box from database

P: 2
i wanT to disply username which is in my database column3
my code:
Expand|Select|Wrap|Line Numbers
  1. Dim cmd As New SqlCommand
  2.  
  3.  
  4.         cmd = con.CreateCommand()
  5.  
  6.         cmd.CommandText = "select * from plane where startdate=@sdate"
  7.         cmd.Parameters.AddWithValue("@sdate", Date.Today())
  8.         Dim rd As SqlDataReader
  9.         rd = cmd.ExecuteReader()
  10.         MsgBox(" USER" &rd(3).ToString.Trim()& "PACKAGE IS END TODAY")
  11.  rd.Close()
  12.  
Attached Images
File Type: jpg Untitled.jpg (34.8 KB, 348 views)
Dec 30 '12 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,383
And what's the problem? Are you getting an error message? What's the message? Is it not doing what you want? What is it doing instead?

You should also be aware that column numbering starts at 0.
Dec 30 '12 #2

P: 2
on msgbox line code errror: Invalid attempt to read when no data is present.
Dec 30 '12 #3

Rabbit
Expert Mod 10K+
P: 12,383
That error means you didn't call the read method of the datareader. You have to call that first before trying to access any of the data.
Dec 31 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.