Click here to Skip to main content
15,893,722 members
Home / Discussions / C#
   

C#

 
AnswerRe: Input string was not in a correct format Pin
Luc Pattyn17-Aug-07 1:38
sitebuilderLuc Pattyn17-Aug-07 1:38 
Questionupdating a DB using a windows form Pin
helloise16-Aug-07 23:49
helloise16-Aug-07 23:49 
AnswerRe: updating a DB using a windows form Pin
Giorgi Dalakishvili16-Aug-07 23:55
mentorGiorgi Dalakishvili16-Aug-07 23:55 
AnswerRe: updating a DB using a windows form Pin
Rocky#17-Aug-07 1:20
Rocky#17-Aug-07 1:20 
GeneralRe: updating a DB using a windows form Pin
helloise17-Aug-07 1:40
helloise17-Aug-07 1:40 
GeneralRe: updating a DB using a windows form Pin
Rocky#17-Aug-07 1:47
Rocky#17-Aug-07 1:47 
AnswerRe: updating a DB using a windows form Pin
Talal Sultan17-Aug-07 1:33
Talal Sultan17-Aug-07 1:33 
GeneralRe: updating a DB using a windows form Pin
helloise17-Aug-07 4:45
helloise17-Aug-07 4:45 
I have the complete code here:

how do I excecute the insertCommand then, ie what is the code for it? thank you very much....Smile | :)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace MyWindowsApp
{
public partial class AddAndUpdateForm : Form
{
public AddAndUpdateForm()
{
InitializeComponent();
}

private void LastnameTextBox_TextChanged(object sender, EventArgs e)
{
string lastname = LastnameTextBox.Text;
}

private void FirstnameTextBox_TextChanged(object sender, EventArgs e)
{
string firstname = FirstnameTextBox.Text;
}

private void NicknameTextBox_TextChanged(object sender, EventArgs e)
{
string nickname = NicknameTextBox.Text;
}

private void UserNameTextBox_TextChanged(object sender, EventArgs e)
{
string username = UserNameTextBox.Text;
}

private void TelExtTextBox_TextChanged(object sender, EventArgs e)
{
string telephoneExtension = TelExtTextBox.Text;
}

public void OKbutton_Click(object sender, EventArgs e)
{

SqlConnection mySqlConnection = new SqlConnection("server=ISS\\SQLEXPRESS;database=Staff;uid=sa;pwd=xbcprfly");
mySqlConnection.Open();

SqlCommand myCommand = mySqlConnection.CreateCommand();
myCommand.CommandText = "SELECT Lastname, Firstname, TelephoneExtension FROM Staff ORDER BY Lastname";
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(myCommand);

DataSet myDataSet = new DataSet();

SqlCommand insertCommand = new SqlCommand("insert into Staff (Lastname,Firstname,TelephoneExtension) values (lastname,firstname,telephoneExtension)",mySqlConnection);
insertCommand.Parameters.Add("lastname", SqlDbType.NVarChar, 80, "Lastname");
insertCommand.Parameters.Add("firstname", SqlDbType.NVarChar, 80, "Firstname");
insertCommand.Parameters.Add("telephoneExtension", SqlDbType.NVarChar, 50, "TelephoneExtension");

//the following code is making me confused.
//myCommand.ExecuteNonQuery();

//mySqlDataAdapter.Fill(myDataSet, "Staff");
//mySqlDataAdapter.InsertCommand = insertCommand;
//mySqlDataAdapter.Update(myDataSet, "Staff");

//SqlCommand cmd = new SqlCommand(cmdStr, con);
//cmd.ExecuteNonQuery();
//SqlCommandBuilder mySqlCommandBuilder = new SqlCommandBuilder(mySqlDataAdapter);

this.Close();
}

private void Cancelbutton_Click(object sender, EventArgs e)
{
this.Close();
}

private void AddAndUpdate_Load(object sender, EventArgs e)
{

}
}
}
QuestionHow to export datagridview columns to MS Word using c# Pin
Exelioindia16-Aug-07 23:22
Exelioindia16-Aug-07 23:22 
AnswerRe: How to export datagridview columns to MS Word using c# Pin
Giorgi Dalakishvili16-Aug-07 23:30
mentorGiorgi Dalakishvili16-Aug-07 23:30 
GeneralRe: How to export datagridview columns to MS Word using c# Pin
Exelioindia16-Aug-07 23:41
Exelioindia16-Aug-07 23:41 
GeneralRe: How to export datagridview columns to MS Word using c# Pin
Giorgi Dalakishvili16-Aug-07 23:51
mentorGiorgi Dalakishvili16-Aug-07 23:51 
GeneralRe: How to export datagridview columns to MS Word using c# Pin
Exelioindia17-Aug-07 0:11
Exelioindia17-Aug-07 0:11 
QuestionUsing WIndows Controls on a ASPX Page... Pin
amitkadamo16-Aug-07 23:10
amitkadamo16-Aug-07 23:10 
AnswerRe: Using WIndows Controls on a ASPX Page... Pin
rah_sin16-Aug-07 23:32
professionalrah_sin16-Aug-07 23:32 
QuestionCharacter Mode Printing in .Net Pin
amitkadamo16-Aug-07 23:07
amitkadamo16-Aug-07 23:07 
QuestionCompare Word docs Pin
Nitin.raj16-Aug-07 22:54
Nitin.raj16-Aug-07 22:54 
AnswerRe: Compare Word docs Pin
Hessam Jalali16-Aug-07 23:56
Hessam Jalali16-Aug-07 23:56 
QuestionMerge Word docs Pin
Nitin.raj16-Aug-07 22:51
Nitin.raj16-Aug-07 22:51 
AnswerRe: Merge Word docs Pin
Hessam Jalali16-Aug-07 23:46
Hessam Jalali16-Aug-07 23:46 
QuestionLocating Zip folders Pin
Nitin.raj16-Aug-07 22:47
Nitin.raj16-Aug-07 22:47 
AnswerRe: Locating Zip folders Pin
Hessam Jalali16-Aug-07 23:41
Hessam Jalali16-Aug-07 23:41 
GeneralRe: Locating Zip folders Pin
Nitin.raj6-Sep-07 0:16
Nitin.raj6-Sep-07 0:16 
GeneralRe: Locating Zip folders Pin
Hessam Jalali7-Sep-07 9:21
Hessam Jalali7-Sep-07 9:21 
QuestionUsing Dynamically created user control with its parent control Pin
b_the_technocrat16-Aug-07 22:43
b_the_technocrat16-Aug-07 22:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.