New to VB.NET...HELP REQUIRED IMMEDIATELY

santosh singh

New member
Joined
Jan 27, 2005
Messages
2
Programming Experience
Beginner
Hi,
I'm new to VB.NET..I'm developing a login page..
I'm getting a lot of errors..please help me out..

the errors im getting are...

System.InvalidOperationException: ExecuteReader requires an open andavailable Connection. The connection's current state is Open, Fetching.atSystem.Data.OleDb.OleDbCommand.ValidateConnectionAndTransaction(Stringmethod, Int32& localState) atSystem.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehaviorbehavior, String method) atSystem.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)at System.Data.OleDb.OleDbCommand.ExecuteReader() atbt.index.Page_Load(Object sender, EventArgs e) ind:\inetpub\wwwroot\bt\index.aspx.vb:line 56

the code in the .aspx.vb page is..
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
Try



Dim MyConn As OleDbConnection = NewOleDbConnection(ConfigurationSettings.AppSettings("strConn"))
Dim strVisitor As String
Dim visitorCmd As OleDbCommand
Dim vRdr As OleDbDataReader
strVisitor = "select max(v_id) from visitor"
visitorCmd = New OleDbCommand(strVisitor, MyConn)
MyConn.Open()
Dim old_visitor As Integer
Dim new_visitor As Integer

vRdr = visitorCmd.ExecuteReader()
While vRdr.Read()
If Not IsDBNull(visitorCmd.ExecuteReader()) Then
old_visitor = vRdr.Item(0)
End If
End While

new_visitor = old_visitor + 1
lblvisitor.Text = new_visitor
MyConn.Close()

Catch ex As Exception
Response.Write(ex)
End Try

End If
End Sub


Please help me out..

Your help will be much appreciated..

thanks a lot.
bye
 

santosh singh

New member
Joined
Jan 27, 2005
Messages
2
Programming Experience
Beginner
one more help needed...

hi,
thanks a lot for the help...i debugged my error...i need one more help...
I wanted to know how to send mail with subject Ref_id(coming fromdatabase) with the contents of the webform as the body of the mail.

thanks in advance,


bye,
santosh
 

elloco999

Well-known member
Joined
Dec 21, 2004
Messages
49
Programming Experience
5-10
I don't know much about webforms, so I can't help you to get the contents from it. But to send an email use the following:

Imports System.Web.Mail

Try
Dim email As New MailMessage

email.To = strTo
email.Cc = strCc
email.Bcc = strBcc
email.From = strFrom
email.Body = strBody
email.Subject = strSubject
email.BodyFormat = MailFormat.Text

SmtpMail.SmtpServer = "mailgate.telecom.ptt.nl"
SmtpMail.Send(email)

Return True
Catch ex As Exception
Return False
End Try

You will have to reference the system.web.dll namespace to use this.

Succes with your project.
El Loco
 
Top Bottom