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 2 1687
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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
|
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...
|
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
| |
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...
|
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
|
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:
|
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
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |