|
I have a combo box on form FrmFinance and it has lots of values and a "Other" selection. If you select it, a dialog window opens, Dialog1. What I want is that on Dialog1 form there is a textbox called txtMake and when you press OK btnOK on the dialog1 form, the item gets added to cmbmake (combo box) on FrmFinance. I don't want any values removed from the combobox, just add what is in the textbox when you press OK
Any ideas?
In the end we're all just the same
|
|
|
|
|
At Last found the solution to this problem previously I was also facing somewhat similar problem here is the solution which worked for me.
In your form2 declare a Class level variable of form type e.g.
Dim oForm as Form
now in the Load event of form2 just make this equal to the 'ActiveForm' property of frmFinance e.g.
oForm = frmFinance.ActiveForm
Now just enter the following code in the Button Click event handler or in whatever event you want to use in order to add items to the Combobox e.g.
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
CType(oForm, frmFinance).cboMake.Items.Add(Me.txtMake.Text)
End Sub
As it helped me I hope it help you too... Good Luck !
AliAmjad(MCP)
First make it Run THEN make it Run Fast!
|
|
|
|
|
OK, but maybe you also want:
- to make sure the value is not already present;
- sort the values;
- remove some when there are too many values.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I got that to work, just changed "Dim oForm as Form" to "Public oForm as Form", thanks. Now how would I remove all items I added to combo box without removing all items? Also, when you click button, I want the combobox to focus on the new added item
In the end we're all just the same
|
|
|
|
|
i m using Smtp for sending mail. I m getting body text from an html editor. This editor uses webbrowser control. Problem is this, when i put an image on the webbrowser control and send it to a mailing address it don't show the pic but all the test is ok.
here's the code i use.
Dim MailObj As Net.Mail.MailMessage = New Net.Mail.MailMessage()
MailObj.To.Add("sampleemailaddress@exampledomain.com")
MailObj.From = New Net.Mail.MailAddress("myemailaddress@somedomain.com", "King")
mailObj.Priority = Net.Mail.MailPriority.Normal
MailObj.Subject = "This is test mail"
mailObj.Body = WebBrowser1.DocumentText
Dim smtpcli As Net.Mail.SmtpClient = New Net.Mail.SmtpClient("smtp.gmail.com", 587)
smtpcli.EnableSsl = True
smtpcli.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
smtpcli.Credentials = New Net.NetworkCredential("someemailaddress@gmail.com", "password")
Try
smtpcli.Send(MailObj)
MsgBox("Email successfully delivered.")
Catch ex As Exception
MsgBox(ex.ToString())
End Try
Thx in advance for any help.....
King
|
|
|
|
|
Try and change the mail type to HTML and then you can send anything formatted well in HTML.
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
Just declare a MailAttachment object give the path of Image to its constructor and then Add it into the Attachment collection of your Mail Message object e.g.
Dim imgAt As New MailAttachment("ImagePath")
MailObj.Attachments.Add(imgAt)
Good Luck !
AliAmjad(MCP)
First make it Run THEN make it Run Fast!
|
|
|
|
|
I am having a problem with the MemberUsername record in my datMember table.
I got the error "IndexOutOfRangeException Was Unhandled by user code when i tried to run my application.
I double check the database.
I declare the MemberUsername as varchar 50
Is tat cause the IndexOutOfRange?
I also have checked the uppercase and lowercase letter too..Nothing is wrong with that..
What would be the problem?
Your help is very much appreciated to me as a beginner..thanks a lot.
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim conMbr As New SqlConnection
Dim cmdMbr As New SqlCommand
Dim sqlReader As SqlDataReader
Dim strVerifyMbr As String
conMbr = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename='C:\Program
Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\GpsCinema.mdf';Initial Catalog=GpsCinema;Persist Security Info=True;User ID=sa;Password=password;MultipleActiveResultSets=True;Connect Timeout=30;User Instance=False;Context Connection=False")
conMbr.Open()
strVerifyMbr = "SELECT MemberId FROM datMember WHERE memberUserName='" + txtUserId.Text + "' AND memberPassword='" + txtPwd.Text + " '"
cmdMbr = New SqlCommand(strVerifyMbr, conMbr)
Dim checkUsr As String = ""
sqlReader = cmdMbr.ExecuteReader
While sqlReader.Read
If txtUserId.Text = Convert.ToString(sqlReader("MemberUsername")) Then
If txtPwd.Text = Convert.ToString(sqlReader("memberPassword")) Then
Session("username") = sqlReader("memberUsername")
Session("password") = sqlReader("memberPassword")
Server.Transfer("MainUser.aspx")
Else
Response.Write("window.alert('Invalid Password. Please try again.');<" + "/script>")
Server.Transfer("MainUser.aspx")
End If
End If
checkUsr = "Failed"
End While
If checkUsr = "Failed" Then
Response.Write("<SCRIPT lanquage='JScript'>window.alert('Invalid Username! Please Try Again.');<" + "/SCRIPT>")
Server.Transfer("MainUser.aspx")
End If
conMbr.Close()
End Sub
<div class="ForumSig">Life is up and down
Nevertheless,never give up hope and be confident to yourself</div>
|
|
|
|
|
kc_renji wrote: What would be the problem?
What line is causing the exception? You didn't say.
kc_renji wrote: strVerifyMbr = "SELECT MemberId FROM datMember WHERE memberUserName='" + txtUserId.Text + "' AND memberPassword='" + txtPwd.Text + " '"
The above line is using SQL Injection. It is vulnerable to attack. Please read SQL Injection Attacks and Tips on How to Prevent Them[^]
kc_renji wrote: Session("password") = sqlReader("memberPassword")
Why do you need to store the password in the session. This is privileged information, it shouldn't be passed around so freely. It would be better to store the password as a salted hash and compare the hash values.
kc_renji wrote: Response.Write("window.alert('Invalid Password. Please try again.');<" + "/script>")</blockquote>
Never tell the user this much detail. It is a security risk. Tell them that the user name and password don't match.
Also, you shouldn't have database code in the presentation layer. There is no protection for the connection or reader in case something fails with the database interaction (i.e. you have no Try/Catch/Finally blocks)
<div class="ForumSig"><hr><small>Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
<b>My <a href="http://www.colinmackay.net">website</a></b></div>
|
|
|
|
|
This line cause the error..
If txtUserId.Text = Convert.ToString(sqlReader("MemberUsername")) Then
Thanks
Life is up and down
Nevertheless,never give up hope and be confident to yourself
|
|
|
|
|
I think I've seen the problem.
Your query is SELECT MemberId ...
You are then attempting to read memberUsername and memberPassword from the query. These don't exist.
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
so the query would be SELECT memberUsername and memberPassword and delete the WHERE query?
Life is up and down
Nevertheless,never give up hope and be confident to yourself
|
|
|
|
|
kc_renji wrote: so the query would be SELECT memberUsername and memberPassword and delete the WHERE query?
WHERE is not a query, it is a clause of the SELECT query.
Your query should be what works. Your current query and code do not match. They need to match. From what I've seen of your code neither are robust enough to form a good solution.
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
Erm i am not really understand that
Since the user enter their name and password
Should the query would verify if the name and password entered would match their memberID???
If not..what should i do?
Life is up and down
Nevertheless,never give up hope and be confident to yourself
|
|
|
|
|
kc_renji wrote: Should the query would verify if the name and password entered would match their memberID???
If not..what should i do?
I've already given you lots of advice.
Your query should not be returning passwords. It should probably just be returning the MemberID. If no rows are returned then obviously the login has failed.
You should store the memberID in the session as that will be connected to other parts of the system. (Assuming the database is well designed)
You should follow the other advice I've given, especially about SQL Injection Attacks. Your code is very weak and quite vulnerable to attack.
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
Thanks a lot..I have solved my problems
^_^
Life is up and down
Nevertheless,never give up hope and be confident to yourself
|
|
|
|
|
I am not very expert and i am trying to make simple billinvoice soft.
my question is when we enter ,how cursor will go to the next column,and also how new billno generate when perivious save.
|
|
|
|
|
vb.net8 wrote: I am not very expert and i am trying to make simple billinvoice soft.
my question is when we enter ,how cursor will go to the next column,and also how new billno generate when perivious save.
If you are dealing with regular textboxes, all you have to do is to either set the "Tab Order" for the fields, or force focus to the field you want using:
<br />
[Field Name].Focus()<br />
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
Hi...
Firstly i want to know which is the control u are using to enter the data...
Can u be plz more specific about what exactly u understand by saving invoice..
|
|
|
|
|
Hii ,
I am creating a datagridview at runtime .And i am assinging the rowheaders and column headers using Input Box .Now,I enter some values in cells .
It is showing the values Consistently .
Now my task is to save the Datagridview into xml and retrieve the same datagridview cell values and header values .
Please help me in writing the grid cell values ???
DVS
|
|
|
|
|
when i try to run the appication and login, there is an error SqlException was unhandle by the user code, Must declare the scalar variable "txtUserId"..What is that mean??Im still a beginner..
Please help.here is the code:
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim conMbr As New SqlConnection
Dim cmdMbr As New SqlCommand
Dim sqlReader As SqlDataReader
Dim strVerifyMbr As String
conMbr = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename='C:\Program
Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\GpsCinema.mdf';Initial
Catalog=GpsCinema;Persist Security Info=True;User
ID=sa;Password=password;MultipleActiveResultSets=True;Connect Timeout=30;User
Instance=False;Context Connection=False")
conMbr.Open()
strVerifyMbr = "SELECT MemberId FROM datMember WHERE memberUserName=@txtUserId.text AND
memberPassword=@txtPwd.Text"
cmdMbr = New SqlCommand(strVerifyMbr, conMbr)
Dim checkUsr As String = ""
(CODE ERROR)here ->sqlReader = cmdMbr.ExecuteReader
While sqlReader.Read
If txtUserId.Text = Convert.ToString(sqlReader("memberUsername")) Then
If txtPwd.Text = Convert.ToString(sqlReader("memberPassword")) Then
Session("username") = sqlReader("memberUsername")
Session("password") = sqlReader("memberPassword")
Server.Transfer("MainUser.aspx")
Else
Response.Write("window.alert('Invalid Password.
Please try again.');<" + "/script>")
Server.Transfer("MainUser.aspx")
End If
End If
checkUsr = "Failed"
End While
If checkUsr = "Failed" Then
Response.Write("<SCRIPT lanquage='JScript'>window.alert('Invalid Username! Please Try Again.');<" + "/SCRIPT>")
Server.Transfer("MainUser.aspx")
End If
conMbr.Close()
End Sub
<div class="ForumSig">Life is up and down
Nevertheless,never give up hope and be confident to yourself</div>
|
|
|
|
|
kc_renji wrote: strVerifyMbr = "SELECT MemberId FROM datMember WHERE memberUserName=@txtUserId.text AND
memberPassword=@txtPwd.Text"
You should change this to:
strVerifyMbr = "SELECT MemberId FROM datMember WHERE memberUserName='" + txtUserId.text + "' AND memberPassword=' + txtPwd.Text + "'"
However you are susceptible to SQL injection attacks if you try this approach. You should consider using stored procedures for database operations and pass parameters to them.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Thanks.You have solved my problems.. ^_^
Life is up and down
Nevertheless,never give up hope and be confident to yourself
|
|
|
|
|
Hi,
As we have AutoGeneratedColumns property in GridView of ASP.Net Framework can we have the same functionality in vb.net ???
Thanks
|
|
|
|
|
VB.NET has nothing to do with it.
Yes, auto-generated columns exist with the DataGridView in Windows Forms. In fact, if you don't supply columns yourself, autogen'd columns are made by default.
|
|
|
|