CFanatic

Go Back   CFanatic > Programming > C# Programming

Join CFanatic Forum Now

Combo Box using SQL problem in C sharp topic posted under C# Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 09-07-2010, 08:19 AM
Junior Member
 
Join Date: Sep 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Maher Baloch is on a distinguished road
| More
Combo Box using SQL problem in C sharp

hey i'm using C Sharp with Sql Server 2005
i have created two table which are as

table 1( CardType): Cardcode, Description.
table 2(CreditCard):Cardcode,number, expirationdate,SecCode.

the both the table having relation between them of Cardcode.

but when i used Combo box in C sharp to display the value of CardType.description it work
but when i want to save the value of cardType.description to creditcard.cardcode it is not working
can anybody over here tell me how itz work

public partial class CreditCard : Form
{
public CreditCard()
{
InitializeComponent();
}

private void CreditCard_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'inFlowDataSet.Card_Type' table. You can move, or remove it, as needed.
this.card_TypeTableAdapter.Fill(this.inFlowDataSet .Card_Type);

}

private void button1_Click(object sender, EventArgs e)
{
string ConnectionString = "Data source=MAHER-PC\\SQLEXPRESS1;Initial Catalog=inFlow;Integrated Security=true";
SqlConnection MyConnection = new SqlConnection(ConnectionString);

string SQLquery = "Insert into Credit_Card(Card_code,number,Expiration_Date,Sec_C ode)";
SQLquery += " values(@Card_code,@number,@Expiration_Date,@Sec_Co de)";

try
{
MyConnection.Open();
SqlCommand Cmd = new SqlCommand(SQLquery, MyConnection);
Cmd.Parameters.AddWithValue("@Card_code", card_TypeTableAdapter = CreditCard.Card_code comboBox1.Text.ToString());
Cmd.Parameters.AddWithValue("@number", Convert.ToInt64(textBox1.Text));
Cmd.Parameters.AddWithValue("@Expiration_Date", textBox2.Text);
Cmd.Parameters.AddWithValue("@Sec_Code", (textBox3.Text).ToUpper());
Cmd.ExecuteNonQuery();
MessageBox.Show("records successfully added", "Howdy", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Close();
}
catch (SqlTruncateException sqlTruncateEx)
{
MessageBox.Show(sqlTruncateEx.Message);
}
catch (SqlTypeException sqlTypeEx)
{
MessageBox.Show(sqlTypeEx.Message);
}


catch (Exception er)
{
MessageBox.Show(er.Message);


//}

finally
{

MyConnection.Close();

}

}
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
C Sharp help on pointers unmanaged code augusbas C# Programming 0 09-05-2010 09:15 AM
Please Help: Populate Combo box from text file samweb$ C# Programming 0 08-29-2010 08:12 AM
Problem reading from combo box yComms C# Programming 0 08-28-2010 03:00 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 04:34 PM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board