|
Ok..this is the exact query i am using....
Function testUpdate(ByVal appId As Integer, ByVal fname As String, ByVal lname As String) As Integer
Dim connectionString As String = "server='(local)'; trusted_connection=true; database='TESTDBfhms'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "UPDATE [R_Application] SET [Fname]=@Fname, [Lname]=@Lname WHERE ([R_Application]."& _
"[AppId] = @AppId)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_appId As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_appId.ParameterName = "@AppId"
dbParam_appId.Value = appId
dbParam_appId.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_appId)
Dim dbParam_fname As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_fname.ParameterName = "@Fname"
dbParam_fname.Value = fname
dbParam_fname.DbType = System.Data.DbType.[String]
dbCommand.Parameters.Add(dbParam_fname)
Dim dbParam_lname As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_lname.ParameterName = "@Lname"
dbParam_lname.Value = lname
dbParam_lname.DbType = System.Data.DbType.[String]
dbCommand.Parameters.Add(dbParam_lname)
Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End Try
Return rowsAffected
End Function
Nab
|
|
|
|
|
There is nothing wrong with that code.
Debug the code and watch where you get the values from, as I suggested in the other thread.
---
single minded; short sighted; long gone;
|
|
|
|
|
I cant seem to remember how to record keystrokes. Basically i need to use the keystroke value in an IF Statement to say,
if back or delete were pressed then
end if
thanks in advance
Karma
|
|
|
|
|
The windows form as a KeyPress event that you can look at to retrieve the keystroke.
CleAkO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
Here is some code that should work for you...
Private Sub yourtextbox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles yourtextbox.KeyDown
'Only allow some control keys
If e.KeyValue = Keys.Delete OrElse e.KeyValue = Keys.Back Then
'good key press
Else
e.Handled = True
End If
End Sub
Hope that helps.
Ben
|
|
|
|
|
use the key down event handler as below
Private Sub txtTendered_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtTendered.KeyDown
If e.KeyCode = Keys.delete Then
do something here
elseif e.keycode = keys.enter then
do something else
end if
end sub
hope this helps
Nab
|
|
|
|
|
hi there i hope you can help me to find a code for this program..i need it asap cause this is my exam...i hope my mgrespond d2...thankz..uumwaaaaaaaaaahh
at last im officially a member nah?!watz up guyz!
|
|
|
|
|
This same question is posted weekly, just search for it.
CleAkO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
Let me get this straight. You want us to find prewritten code for you, I'm assuming it's a quiz program, so you can pass an exam?? Correct?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
i need it asap cause this is my exam
He says so right there.
CleAkO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
You can't fault his honesty.
|
|
|
|
|
I just wanted to see if he'd cinch the rope around his neck tight enough, in light of point number 9, here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: I just wanted to see if he'd cinch the rope around his neck tight enough, in light of point number 9
Oh, yes....
|
|
|
|
|
6 months from now, he'll be a new hire at your work, and your job will be to train him. He'll probably ask you to write his code for him then, too.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
If he walks in the door, I'm walking out! Hell! I'm ready to walk out the door NOW!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello,
Does any one have any information for sending e-mail using exchange server 2003.
I am using vs 2005 and need to be able to send e-mail from a windows application and have the exchange server send it to the destination e-mail.
If anyone can point me in the right direction or have some information that will be a great help. I have been told that this is very difficult to do.
Many thank for any help you can give me,
Steve
|
|
|
|
|
first you need to import this mail class
Imports System.Web.Mail
Dim mail As New MailMessage
mail.To = anyone@someDomain
mail.From = user@yourDomain
mail.Subject = "message subject comes here"
mail.Body = "body of the message.. could be from a textbox"
SmtpMail.SmtpServer = "MailServerName" 'your real server name goes here
SmtpMail.Send(mail) ' this section is what sends the mail...
this is perfectly fine....i have use it..
the from email account..must exist on the exchange mail server account.. so if you have an account on that server.. use it for the from section or just create a temp account to be used for this purpose..
hope this helps..
Nab
|
|
|
|
|
Hello,
Thanks for your help. The code i used is below. But I got a warning saying that using system.web.mail is obsolete and system.net.mail is the recommended to be used instead.
Also using the MS Exchange is very slow, i tried to send an e-mail to my hotmail and gmail account it takes more than 10 minutes to get there.
Is there any setting on the microsoft exchange server that need to be set?
Another quick question, is there a way to get the server name and the e-mail account automatically instead of a user inputting in? They can just click the send button.
Many thanks for your time,
Steve
Code for using system.web.mail
<br />
Private Sub btnSendExchangeServer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendExchangeServer.Click<br />
Dim mailMsg As New MailMessage()<br />
<br />
mailMsg.To = "steve@clarityform.com"<br />
mailMsg.From = "steve@clarityform.com"<br />
mailMsg.Subject = "2nd Microsoft Exchange Server Mail Test"<br />
mailMsg.Body = "This email came from MS Exchange Server"<br />
<br />
Try<br />
SmtpMail.SmtpServer = "cf01.clarityforms.com"<br />
SmtpMail.Send(mailMsg)<br />
<br />
Catch ex As Net.Mail.SmtpException<br />
MessageBox.Show(ex.Message)<br />
Catch ex As Exception<br />
MessageBox.Show(ex.Message)<br />
End Try<br />
<br />
End Sub<br />
End Class<br />
Code for using gmail smpt server using system.net.mail
<br />
Private Sub btnSendMail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendMail.Click<br />
Dim msgTo As New MailAddress("steve@clarityforms.com")<br />
Dim msgFrom As New MailAddress("steve@clarityforms.com")<br />
Dim msgSender As New MailAddress("steve@clarityforms.com")<br />
<br />
Dim mailMsg As New MailMessage()<br />
mailMsg.Sender = msgSender<br />
mailMsg.To.Add(msgTo)<br />
mailMsg.Priority = MailPriority.High<br />
mailMsg.CC.Add("Steve1_rm@yahoo.com")<br />
mailMsg.Subject = "This is a mail test"<br />
mailMsg.Body = "This is the body of the e-mail, Enjoy"<br />
mailMsg.From = msgFrom<br />
<br />
Dim client As New SmtpClient("smtp.gmail.com", 587)<br />
client.Credentials = New System.Net.NetworkCredential("steve1.rm@gmail.com", "1apple2")<br />
client.EnableSsl = True<br />
<br />
Try<br />
client.Send(mailMsg)<br />
Catch ex As SmtpException<br />
MessageBox.Show(ex.Message)<br />
Catch ex As Exception<br />
MessageBox.Show(ex.Message)<br />
End Try<br />
<br />
End Sub<br />
|
|
|
|
|
hi i know to create a database in ms access through vb.net but i want to delete a database through vb.net code
is it possible then how to achieve it
thanks
with regards
Balagurunathan
with regards
Balagurunathan.B
|
|
|
|
|
First I would say that it is a bad practice to create and drop real tables from a program. If you are just creating tables for temporary use that is different. Now that I got that out of the way.
Is it not as simple as saying DROP TABLE TABLENAME ?
CleAkO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
CleAkO wrote: First I would say that it is a bad practice to create and drop real tables from a program.
Why?
|
|
|
|
|
Well for most DBs you would need to elevated priviledges in order to drop or add any table other than a #temp table.
CleAkO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
CleAkO wrote: Well for most DBs you would need to elevated priviledges in order to drop or add any table other than a #temp table.
Your original statement was more general than that. Assume that the user has the appropriate privileges. Why would it be bad practice to drop tables from a database in a program?
|
|
|
|
|
I thought we established that all user input is evil and by giving the permission to do this it could be taken advantage of, that's all.
CleAkO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
CleAkO wrote: I thought we established that all user input is evil and by giving the permission to do this it could be taken advantage of
You can sanitise the data to ensure that necessary tables are not dropped. The table may be dropped as part of a larger overall process and the drop functionality is not initiated by any specific user input.
Good (or best) practice shows ways to do things that that have a higher likelyhood of producing positive results. It does not deny the ability to do anything, it merely suggests better ways of doing things. If you need to drop a table then there are good ways of doing that.
The table name is 128 characters maximum (in SQL Server). If you ensure that all table names are made up of only specific characters (e.g. letters and numbers only) you can remove the possibility of people managing to inject malicious code into the drop statement because you can reject invalid characters. You can also surround your table name in square brackets. You can verify that the table exists prior to issuing the drop by querying the INFORMATION_SCHEMA.TABLES view using a parameterised query.
There are lots of things you can do to ensure that if you do need to drop a table from your application, you do it safely.
|
|
|
|