TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
travis.hurst
NA
13
0
General Queries
Sep 8 2004 10:03 AM
I am very new to C# so sorry if I am fumbling my way through this. I am trying to produce an database insert method for saving contact information on a windows form. I need to know a couple of things: 1. Is there a simpler way to pass in parameters 2. How do I get the next unique id for the table from my oracle sequence in C# 3. How do I pass back the database ID from my combo box value instead of the text value. ===================== private void SaveContact() { string strSQL; int i; string strSurname; string strForename; string strTitle; string strPhone; string strFax; string strEmail; int intBusUnit; int intDiv; int intLoc; int intTeam; strSurname = this.txtSurname.Text.Trim(); strForename = this.txtForename.Text.Trim(); strTitle = this.cboTitle.Text.Trim(); strPhone = this.txtPhone.Text.Trim(); strFax = this.txtFax.Text.Trim(); strEmail = this.txtEmail.Text.Trim(); intBusUnit = this.cboBusUnit.SelectedIndex; intDiv = 1; //this.cboDivision.ValueMember; //SelectedValue intLoc = 1; //this.cboLocation.Text; intTeam = 1; //this.cboTeam.Text; strSQL = "INSERT INTO PERSON (ID,SURNAME,FORENAME,TITLE,PHONE,EMAIL,FAX,DIVISIONID,BUSINESSUNITID, LOCATIONID, TEAMID)"; strSQL += "VALUES (20,'"+strSurname+"','"+strForename+"','"+strTitle+"','"+strPhone+"','"+strEmail+"','"+strFax+"',"+intDiv+","+intBusUnit+","+intLoc+","+intTeam+")"; try { // Create database Connection DataProvider.DataProvider provider; Utilities objUtil = new Utilities(); string strConnectionString = objUtil.GetConnectionString(); provider = new DataProvider.DataProvider(strConnectionString,DataProvider.DataProvider.DBType.OleDb); // Execute the insert i = provider.ExecuteNonQuery(strSQL); MessageBox.Show ("New Contact Saved.", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { MessageBox.Show ("Nice one geezer!", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
Reply
Answers (
1
)
SAVING DATA OF DATAGRID
Database control