i have an insert statement on a btn submit comp
this works great
i also have code to send an email,
not sure if it works
when i call my fuction to send the email in my btn send
the email doesnt send and the insert doesnt insert
how messed up is that
Printable View
i have an insert statement on a btn submit comp
this works great
i also have code to send an email,
not sure if it works
when i call my fuction to send the email in my btn send
the email doesnt send and the insert doesnt insert
how messed up is that
so you got some code for us to look at? any error messages?
no error messages
my code for submit is just a basic insert satatement
then
i call my send mail function
Private Sub CompRegConfirmation()
Dim msg As New MailMessage
msg.From = "[email protected]"
msg.To = "[email protected]"
msg.Bcc = "[email protected]"
msg.Subject = " Company registered"
msg.Body = "this is a test"
msg.Body = "helo good mornin vietnam"
msg.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(msg)
End Sub
so id my submit click i have
insert.........
connection close()
compregconfirmation()
end sub
if i do this then no erors appear, no insert to database, and no email is sent either
Can you post the insert statement?
Dim sqlInsertComp As New SqlCommand("INSERT INTO tb_comp_detail(c_companycode,c_comp_name,c_job_title,c_firstname,c_sname,c_houseno,c_street,c_passwo rd,c_town,c_county,c_country,c_comp_email,c_comp_tel,c_comp_registered,c_comp_enabled) VALUES('" & txtUsername.Text & "','" & txtCompanyName.Text & "','Owner','" & txtFirstName.Text & "','" & txtSurname.Text & "','" & txtHouseNo.Text & "','" & txtStreet.Text & "','" & txtPassword.Text & "','Derry','Derry','uk','" & txtEmailAddress.Text & "','" & txtPhoneNo.Text & "',getDate(),'0');", oSQLConn)
oSQLConn.Open()
sqlInsertComp.ExecuteNonQuery()
oSQLConn.Close()
Do you catch exceptions?
no
what do you suggest
Are any exceptions or errors displayed? Sometimes when I have code that doesn't do what its supposed to do and also does not display an error it is because of a caught exception.
Is this is an ASP.NET file, or in the CodeBehind vb file? Can you post the entire methods (the _click method)
the code of the button submit click is just the code above
the insert statement and then call the compregconfirmation method
when i dont call the compregconfirmation the insert works
if i call compregconfirmation in a different button then the email is sent ( on another machine)
but if i try to call it in the button click event
no insert, no email no errors
i have no try catch statements
it is completely baffling i know
if you want me to post the code i will
but its just as above
thanks
I'm just guessing at some of the basic mistakes I made when I first started vb. Just make sure the button method looks like this:
Private Sub btnMyButton_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnMyButton.Click
Make sure the btnMyButton.Click has the correct button and event name.