Click here to Skip to main content
15,904,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i've created a sql database contains 7 tables.
bankacc
cashpay
customer
opening_balance
payment
receievedchq
withdrawal

and also create three forms for customer, bankacc and payments.
bankacc table : bankid,bankname,branchname,accname,accountno
customer table : custid,custname,custadd,tpno
payments table : paymentid,paymentdate,custname,description,chqno,duedate,accname,amount

in payments forms there are two combo boxes for custname and accname
custname combo should be connected to : customer table custname
accname combo should be connected to : bankacc table accname

and want to pass this all record to payments table in database. I am new to c#. can anyone help with coding.
Posted
Comments
Maciej Los 17-Jul-14 2:46am    
WinForms? WebControls?
jo.him1988 17-Jul-14 2:51am    
can you paste your code here so we can see where is the problem??

You can take Pass the combobox item to your database.

use : custnam.SelectedItem.toString()

and for account name : accname.SelectedItem.toString()

if still not able to understand. paste your code so we can understand your problem.
 
Share this answer
 
for Customer Name use

custname.SelectedValue.ToString();

and for Account Name use

accname.SelectedValue.ToString();


SelectedValue property will give you the currently selected value from the ComboBox control. This will work in WinForms.

For WebForms

use SelectedItem property in place of SelectedValue.
 
Share this answer
 
you can use SelectedItem.Text or SelectedItem.ToString()
example
C#
ddlcustname.SelectedItem.Text or ddlcustname.SelectedItem.ToString()


and
C#
ddlaccname.SelectedItem.Text or ddlaccname.SelectedItem.ToString()


One Suggestion
If your custname and accname are editable then you should take CustId and AccId in PaymentTable for data accuracy

Ignore if it's applicable in your case
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900