473,729 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Newb Question....Dat abase 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.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

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

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

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

private void btnAdd_Click(ob ject sender, EventArgs e)
{
NORTHWNDDataSet TableAdapters.E mployeesTableAd apter
employeeTableAd apter =
new
Northwind.NORTH WNDDataSetTable Adapters.Employ eesTableAdapter ();

employeeTableAd apter.Insert();
}

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

this.employeesT ableAdapter.Fil l(this.nORTHWND DataSet.Employe es);

}

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

}*/
}
}

Thanks,
Charles

Jan 13 '07 #1
2 1689
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 employeeTableAd apter.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**********@y ahoo.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.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

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

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

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

private void btnAdd_Click(ob ject sender, EventArgs e)
{
NORTHWNDDataSet TableAdapters.E mployeesTableAd apter
employeeTableAd apter =
new
Northwind.NORTH WNDDataSetTable Adapters.Employ eesTableAdapter ();

employeeTableAd apter.Insert();
}

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

this.employeesT ableAdapter.Fil l(this.nORTHWND DataSet.Employe es);

}

/* 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 employeeTableAd apter.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**********@y ahoo.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.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;

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

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

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

private void btnAdd_Click(ob ject sender, EventArgs e)
{
NORTHWNDDataSet TableAdapters.E mployeesTableAd apter
employeeTableAd apter =
new
Northwind.NORTH WNDDataSetTable Adapters.Employ eesTableAdapter ();

employeeTableAd apter.Insert();
}

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

this.employeesT ableAdapter.Fil l(this.nORTHWND DataSet.Employe es);

}

/* 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
2356
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 experienced C++ programmer. This has allowed me to see many potential areas where the security of a server can be compromised through loopholes in PHP. Granted, with the right knowledge these potential threats can be avoided. But I've just...
1
2206
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 done. in general terms, does it go like this...
0
2128
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 construct a checkbox array in a survey form where one of the choices is "No Preference" which is checked by default. If the victim chooses other than "No Preference", I'd like to uncheck
3
1760
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 get it up and running. I then run winmysqladmin V1.4 (the mysql service is running) When I go to databases inside the admin, it shows on the left side the name of the server and IP address and it has a 'test' database listed below it..... From...
3
1829
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 construct a checkbox array in a survey form where one of the choices is "No Preference" which is checked by default. If the victim chooses other than "No Preference", I'd like to uncheck
6
1537
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 backwards though... This is probably easier to diagram than to describe... Countries -M to1-> Provinces - M to 1-> Cities <-M to 1- Call Centres With the above relationships I am having trouble implementing a simple data entry interface. Basically...
11
1995
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. I have a file named books.txt that contains all the informations on the books. Each book is a struc containing 6 fields written on separated line in the
29
3572
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 one data field - but i'm not sure) :-) Background info:
2
1192
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 formatting and JavaScript issues that require each and every form element's ID to remain unchanged. Unfortunately, whenever
0
8913
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9280
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6016
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.