473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Newb Question....Database Entry Form

Hi,

I'm very new to programming so forgive me for asking the dumb question.
I'm trying to develop a database application using c#, and I'm using
the northwind database. I'm currently using visual c# express edition
2005 as well as sql 2005 express.

Here's the thing I've been trying to figure out. I want to insert a new
row in the Employees Table when I click a button called btnAdd. When I
was learning delphi, I would just put the dataset into insert mode for
instance dataset.insert.

How can I achieve this in visual c# I'm wondering. Here's my code.

Please, let me know if there's anymore details I can give. I usually
find the solution by googling it, but I've been stuck on this for a
while.

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

namespace Northwind
{
public partial class frmEmployeeDB : Form
{
public frmEmployeeDB()
{
InitializeComponent();
}

/* private void frmEmployeeDB_Load(object sender, EventArgs e)
{
NORTHWNDDataSet.EmployeesRow newEmployeesRow;
newEmployeesRow = NORTHWNDDataSet
}*/

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

private void btnAdd_Click(object sender, EventArgs e)
{
NORTHWNDDataSetTableAdapters.EmployeesTableAdapter
employeeTableAdapter =
new
Northwind.NORTHWNDDataSetTableAdapters.EmployeesTa bleAdapter();

employeeTableAdapter.Insert();
}

private void frmEmployeeDB_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the
'nORTHWNDDataSet.Employees' table. You can move, or remove it, as
needed.

this.employeesTableAdapter.Fill(this.nORTHWNDDataS et.Employees);

}

/* private void bindingSource1_CurrentChanged(object sender,
EventArgs e)
{

}*/
}
}

Thanks,
Charles

Jan 13 '07 #1
2 1665
Hi

In your code when you click the button (btnAdd_Click) you are creating an
object and inserting a new row..

Create the object in the class when it loads (that means just one time), and
just leave the employeeTableAdapter.Insert() method inside the btnAdd_Click

BTW the Insert() method takes some arguments, those are the fields from the
table the TableAdapter is referenced (in this case Employees table), so you
may need to pass the values to insert in that table.

I did this one time in an app, i'm not an expert on the subject, but i hope
this helps you :)

--
VBA
"ul**********@yahoo.com" wrote:
Hi,

I'm very new to programming so forgive me for asking the dumb question.
I'm trying to develop a database application using c#, and I'm using
the northwind database. I'm currently using visual c# express edition
2005 as well as sql 2005 express.

Here's the thing I've been trying to figure out. I want to insert a new
row in the Employees Table when I click a button called btnAdd. When I
was learning delphi, I would just put the dataset into insert mode for
instance dataset.insert.

How can I achieve this in visual c# I'm wondering. Here's my code.

Please, let me know if there's anymore details I can give. I usually
find the solution by googling it, but I've been stuck on this for a
while.

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

namespace Northwind
{
public partial class frmEmployeeDB : Form
{
public frmEmployeeDB()
{
InitializeComponent();
}

/* private void frmEmployeeDB_Load(object sender, EventArgs e)
{
NORTHWNDDataSet.EmployeesRow newEmployeesRow;
newEmployeesRow = NORTHWNDDataSet
}*/

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

private void btnAdd_Click(object sender, EventArgs e)
{
NORTHWNDDataSetTableAdapters.EmployeesTableAdapter
employeeTableAdapter =
new
Northwind.NORTHWNDDataSetTableAdapters.EmployeesTa bleAdapter();

employeeTableAdapter.Insert();
}

private void frmEmployeeDB_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the
'nORTHWNDDataSet.Employees' table. You can move, or remove it, as
needed.

this.employeesTableAdapter.Fill(this.nORTHWNDDataS et.Employees);

}

/* private void bindingSource1_CurrentChanged(object sender,
EventArgs e)
{

}*/
}
}

Thanks,
Charles

Jan 13 '07 #2
Thanks alot as soon as I get to my computer I'll look into this..

Again, thanks for the tip.
Charles
VBA wrote:
Hi

In your code when you click the button (btnAdd_Click) you are creating an
object and inserting a new row..

Create the object in the class when it loads (that means just one time), and
just leave the employeeTableAdapter.Insert() method inside the btnAdd_Click

BTW the Insert() method takes some arguments, those are the fields from the
table the TableAdapter is referenced (in this case Employees table), so you
may need to pass the values to insert in that table.

I did this one time in an app, i'm not an expert on the subject, but i hope
this helps you :)

--
VBA
"ul**********@yahoo.com" wrote:
Hi,

I'm very new to programming so forgive me for asking the dumb question.
I'm trying to develop a database application using c#, and I'm using
the northwind database. I'm currently using visual c# express edition
2005 as well as sql 2005 express.

Here's the thing I've been trying to figure out. I want to insert a new
row in the Employees Table when I click a button called btnAdd. When I
was learning delphi, I would just put the dataset into insert mode for
instance dataset.insert.

How can I achieve this in visual c# I'm wondering. Here's my code.

Please, let me know if there's anymore details I can give. I usually
find the solution by googling it, but I've been stuck on this for a
while.

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

namespace Northwind
{
public partial class frmEmployeeDB : Form
{
public frmEmployeeDB()
{
InitializeComponent();
}

/* private void frmEmployeeDB_Load(object sender, EventArgs e)
{
NORTHWNDDataSet.EmployeesRow newEmployeesRow;
newEmployeesRow = NORTHWNDDataSet
}*/

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

private void btnAdd_Click(object sender, EventArgs e)
{
NORTHWNDDataSetTableAdapters.EmployeesTableAdapter
employeeTableAdapter =
new
Northwind.NORTHWNDDataSetTableAdapters.EmployeesTa bleAdapter();

employeeTableAdapter.Insert();
}

private void frmEmployeeDB_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the
'nORTHWNDDataSet.Employees' table. You can move, or remove it, as
needed.

this.employeesTableAdapter.Fill(this.nORTHWNDDataS et.Employees);

}

/* private void bindingSource1_CurrentChanged(object sender,
EventArgs e)
{

}*/
}
}

Thanks,
Charles
Jan 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Xizor | last post by:
Ok, I'm new to PHP and MySQL. I've been going through tutorials, reading the documentation, and looking through web sites. PHP to me seems great! With MySQL it seems even better. However, I'm an...
1
by: skeeterbug | last post by:
hi all, i'm new to using php, adodb and pgsql. i have a need to enter data into a database. however, i can't find a web example or tutorial that explains the nuts and bolts of how this is...
0
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to...
3
by: Walter | last post by:
But I'm stumped..... I've got a windows 2000 server and I am trying to set up PHPBB on it using a mysql database.. I am very inexperienced on this..... Ive installed mysql V4.0.20d and I can...
3
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to...
6
by: Noozer | last post by:
I'm developing a database using MS Access and have come across a problem. The majority of my database is pretty straightforward "many to one" relationships. I have one relationship that is...
11
by: The_Kingpin | last post by:
Hi all, I'm new to C programming and looking for some help. I have a homework project to do and could use every tips, advises, code sample and references I can get. Here's what I need to do....
29
by: MP | last post by:
Greets, context: vb6/ado/.mdb/jet 4.0 (no access)/sql beginning learner, first database, planning stages (I think the underlying question here is whether to normalize or not to normalize this...
2
by: Neo Geshel | last post by:
Greetings! I have a rather unusual request about a rather basic need. I need to be able to bind data to a page, but WITHOUT using a Repeater, DataGrid or DataList. Why? Well, I have some...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.