Thursday, March 29, 2012

Error From Maintenance Plan

I am getting the following error in my Maintenance Plan. It looks as
if it is just one table (according to the Object id). My question is
how do I determine which table this is when all I have is this Object
ID?
Mark
[7] Database pcms: Check Data and Index Linkage...
[Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 2576:
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:28607) object ID
507864876 index ID 2 but was not detected in the scan.
The following errors were found:
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:28607) object ID
507864876 index ID 2 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:96558) object ID
507864876 index ID 9 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:97687) object ID
507864876 index ID 10 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:111104) object ID
507864876 index ID 11 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:117681) object ID
507864876 index ID 12 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:117690) object ID
507864876 index ID 13 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 12
allocation errors and 0 consistency errors in table '(Object ID
507864876)' (object ID 507864876).
[Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 12
allocation errors and 0 consistency errors in database 'pcms'.
[Microsoft][ODBC SQL Server Driver][SQL Server]repair_allow_data_loss
is the minimum repair level for the errors found by DBCC CHECKDB (pcms
repair_fast).
** Execution Time: 0 hrs, 2 mins, 22 secs **Hi Mark,
As all the indexes are non clustered (their indid is greater than 1) you
should be able to solve this issue by rebuilding the indexes on your table.
You can find the name of the table that is affected with
OBJECT_NAME(507864876), and you can then rebuild the indexes with DBCC
DBREINDEX(<table name> ). Make a backup of your database first though.
Jacco Schalkwijk
SQL Server MVP
"Mark" <markcash@.Hotmail.com> wrote in message
news:57bdc737.0402160616.508ce27f@.posting.google.com...
> I am getting the following error in my Maintenance Plan. It looks as
> if it is just one table (according to the Object id). My question is
> how do I determine which table this is when all I have is this Object
> ID?
> Mark
>
> [7] Database pcms: Check Data and Index Linkage...
> [Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 2576:
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:28607) object ID
> 507864876 index ID 2 but was not detected in the scan.
> The following errors were found:
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:28607) object ID
> 507864876 index ID 2 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:96558) object ID
> 507864876 index ID 9 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:97687) object ID
> 507864876 index ID 10 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:111104) object ID
> 507864876 index ID 11 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:117681) object ID
> 507864876 index ID 12 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:117690) object ID
> 507864876 index ID 13 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 12
> allocation errors and 0 consistency errors in table '(Object ID
> 507864876)' (object ID 507864876).
> [Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 12
> allocation errors and 0 consistency errors in database 'pcms'.
> [Microsoft][ODBC SQL Server Driver][SQL Server]repair_allow_data_loss
> is the minimum repair level for the errors found by DBCC CHECKDB (pcms
> repair_fast).
> ** Execution Time: 0 hrs, 2 mins, 22 secs **

Error from Maintenance plan

Hi there,
I get an error from the maintenance plan, when it every weekend reorganizes
the data and index tables:
[Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 1934: [Microsoft]&#
91;ODBC SQL
Server Driver][SQL Server]DBCC failed because the following SET options
have
incorrect settings: 'QUOTED_IDENTIFIER, ARITHABORT'.
I wonder if it could be because i have an calculated field in the table,
[FullName] AS ([LastName] + ', ' + [FirstName]) ?
The table is create as follows:
CREATE TABLE [dbo].[Assigner] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[FirstName] [varchar] (25) COLLATE SQL_SwedishStd_Pref_CP1_CI_AS NOT
NULL ,
[LastName] [varchar] (30) COLLATE SQL_SwedishStd_Pref_CP1_CI_AS NOT
NULL ,
[FullName] AS ([LastName] + ', ' + [FirstName]) ,
[CustomerGroup_id] [int] NOT NULL ,
[Deactivated] [bit] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Assigner] WITH NOCHECK ADD
CONSTRAINT [PK_Assigner] PRIMARY KEY CLUSTERED
(
[id]
) WITH FILLFACTOR = 70 ON [PRIMARY]
GO
ALTER TABLE [dbo].[Assigner] ADD
CONSTRAINT [FK_Assigner_CustomerGroup] FOREIGN KEY
(
[CustomerGroup_id]
) REFERENCES [dbo].[CustomerGroup] (
[id]
)
GOJohn
This SELECT stetement will produce a syntax error
You may want to change it as SELECT ([LastName] + ', ' + [FirstName
]) AS
[FullName] FROM .....
"John Boghossian" <john.boghossian@.investorab.com> wrote in message
news:eS2iwyljEHA.3724@.TK2MSFTNGP11.phx.gbl...
> Hi there,
> I get an error from the maintenance plan, when it every weekend
reorganizes
> the data and index tables:
> [Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 1934: [Microsoft][ODB
C
SQL
> Server Driver][SQL Server]DBCC failed because the following SET options[/vbcol
]
have[vbcol=seagreen]
> incorrect settings: 'QUOTED_IDENTIFIER, ARITHABORT'.
> I wonder if it could be because i have an calculated field in the table,
> [FullName] AS ([LastName] + ', ' + [FirstName]) ?
>
> The table is create as follows:
> CREATE TABLE [dbo].[Assigner] (
> [id] [int] IDENTITY (1, 1) NOT NULL ,
> [FirstName] [varchar] (25) COLLATE SQL_SwedishStd_Pref_CP1_CI_AS NOT NULL

,
> [LastName] [varchar] (30) COLLATE SQL_SwedishStd_Pref_CP1_CI_AS NOT NULL[
/vbcol]
,[vbcol=seagreen]
> [FullName] AS ([LastName] + ', ' + [FirstName]) ,
> [CustomerGroup_id] [int] NOT NULL ,
> [Deactivated] [bit] NULL
> ) ON [PRIMARY]
> GO
> ALTER TABLE [dbo].[Assigner] WITH NOCHECK ADD
> CONSTRAINT [PK_Assigner] PRIMARY KEY CLUSTERED
> (
> [id]
> ) WITH FILLFACTOR = 70 ON [PRIMARY]
> GO
> ALTER TABLE [dbo].[Assigner] ADD
> CONSTRAINT [FK_Assigner_CustomerGroup] FOREIGN KEY
> (
> [CustomerGroup_id]
> ) REFERENCES [dbo].[CustomerGroup] (
> [id]
> )
> GO
>|||John,
You most probably have either an index on that computed column, or SQL Serve
r has created statistics
on the column. In those situations, whenever you need to rebuild such an ind
ex or statistics, the
connection need special SET options defined. For some reason, Maint wizard d
oesn't set these. You
could try to drop the statistics (DROP STATISTICS), chances are that they wi
ll re-added. You could
tell SQL Server to not create statistics, but the issue might pop up somewhe
re else. To be safe,
perform the DBCC DBREINDEX commands from your own SQL Server Agent job and m
ake sure to set the SET
commands as they need to be set. I'm sure there's a KB on this topic if you
search for appropriate
keywords...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"John Boghossian" <john.boghossian@.investorab.com> wrote in message
news:eS2iwyljEHA.3724@.TK2MSFTNGP11.phx.gbl...
> Hi there,
> I get an error from the maintenance plan, when it every weekend reorganize
s
> the data and index tables:
> [Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 1934: [Microsoft]
[ODBC SQL
> Server Driver][SQL Server]DBCC failed because the following SET option
s have
> incorrect settings: 'QUOTED_IDENTIFIER, ARITHABORT'.
> I wonder if it could be because i have an calculated field in the table,
> [FullName] AS ([LastName] + ', ' + [FirstName]) ?
>
> The table is create as follows:
> CREATE TABLE [dbo].[Assigner] (
> [id] [int] IDENTITY (1, 1) NOT NULL ,
> [FirstName] [varchar] (25) COLLATE SQL_SwedishStd_Pref_CP1_CI_AS
NOT NULL ,
> [LastName] [varchar] (30) COLLATE SQL_SwedishStd_Pref_CP1_CI_AS N
OT NULL ,
> [FullName] AS ([LastName] + ', ' + [FirstName]) ,
> [CustomerGroup_id] [int] NOT NULL ,
> [Deactivated] [bit] NULL
> ) ON [PRIMARY]
> GO
> ALTER TABLE [dbo].[Assigner] WITH NOCHECK ADD
> CONSTRAINT [PK_Assigner] PRIMARY KEY CLUSTERED
> (
> [id]
> ) WITH FILLFACTOR = 70 ON [PRIMARY]
> GO
> ALTER TABLE [dbo].[Assigner] ADD
> CONSTRAINT [FK_Assigner_CustomerGroup] FOREIGN KEY
> (
> [CustomerGroup_id]
> ) REFERENCES [dbo].[CustomerGroup] (
> [id]
> )
> GO
>|||John,
Go with TIbors suggestions... A computed column which is index, etc , then
those settings matter during maint plan stuff... I would suspect you are
getting the error on index rebuild..
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"John Boghossian" <john.boghossian@.investorab.com> wrote in message
news:eS2iwyljEHA.3724@.TK2MSFTNGP11.phx.gbl...
> Hi there,
> I get an error from the maintenance plan, when it every weekend
reorganizes
> the data and index tables:
> [Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 1934: [Microsoft][ODB
C
SQL
> Server Driver][SQL Server]DBCC failed because the following SET options[/vbcol
]
have[vbcol=seagreen]
> incorrect settings: 'QUOTED_IDENTIFIER, ARITHABORT'.
> I wonder if it could be because i have an calculated field in the table,
> [FullName] AS ([LastName] + ', ' + [FirstName]) ?
>
> The table is create as follows:
> CREATE TABLE [dbo].[Assigner] (
> [id] [int] IDENTITY (1, 1) NOT NULL ,
> [FirstName] [varchar] (25) COLLATE SQL_SwedishStd_Pref_CP1_CI_AS NOT NULL

,
> [LastName] [varchar] (30) COLLATE SQL_SwedishStd_Pref_CP1_CI_AS NOT NULL[
/vbcol]
,[vbcol=seagreen]
> [FullName] AS ([LastName] + ', ' + [FirstName]) ,
> [CustomerGroup_id] [int] NOT NULL ,
> [Deactivated] [bit] NULL
> ) ON [PRIMARY]
> GO
> ALTER TABLE [dbo].[Assigner] WITH NOCHECK ADD
> CONSTRAINT [PK_Assigner] PRIMARY KEY CLUSTERED
> (
> [id]
> ) WITH FILLFACTOR = 70 ON [PRIMARY]
> GO
> ALTER TABLE [dbo].[Assigner] ADD
> CONSTRAINT [FK_Assigner_CustomerGroup] FOREIGN KEY
> (
> [CustomerGroup_id]
> ) REFERENCES [dbo].[CustomerGroup] (
> [id]
> )
> GO
>|||> I wonder if it could be because i have an calculated field in the table,
> [FullName] AS ([LastName] + ', ' + [FirstName]) ?
Why would you have this calculated column in the table? I would be tempted
to drop it and run this concatenation in the SELECT proc(s) or even a view.
http://www.aspfaq.com/
(Reverse address to reply.)

Error from Distribution clean up

Hi all,
last 9 april 2004 is occured this error:
"Event Type:Warning
Event Source:SQLServerAgent$SQLQRS
Event Category:Printers
Event ID:208
Date:4/9/2004
Time:6:10:06 AM
User:N/A
Computer:
Description:
The description for Event ID ( 208 ) in Source (
SQLServerAgent$SQLQRS ) cannot be found.
The local computer may not have the necessary registry
information or message DLL files to display messages from
a remote computer.
The following information is part of the event:
Distribution clean up: Stride3Distribution,
0xAF771833463E8642AD563AA9C8901B99, Failed, 4/9/2004
6:10:00 AM, The job failed.
Unable to determine if the owner (OTP\sysadmin19) of job
Distribution clean up: Stride3Distribution has server
access (reason: Violation of PRIMARY KEY
constraint 'PK__syscachedcredent__3F9B6DFF'.
Cannot insert duplicate key in
object 'syscachedcredentials'. [SQLSTATE 23000] (Error
2627) The statement has been terminated. [SQLSTATE 01000]
(Error 3621)).."
I need of help, someone can help me, please
EmSga
I have seen part of this error message before:
"Unable to determine if the owner (OTP\sysadmin19) of job
Distribution clean up: Stride3Distribution has server
access."
In this case you can set the job to be owned by sa and avoid the active directory lookup.
As for the rest, can you check that the sql agent running the replication job has the correct rights on the other server.
Regards,
Paul Ibison
sql

Error from AS2005 - Binding for column 'xxxxx' is not a ColumnBinding type

I've seen this question come up a couple times on the public .olap newsgroup, but I've never seen an answer, so I'm going to give it another try:

I'm getting an error when I try to incrementally process my SSAS 2005 cube:

Errors in the high-level relational engine. The binding for the 'column-name' column is not a ColumnBinding type.

In this case, the column name that's given is a name that occurs in only 1 table in the underlying schema, so I know unambiguously which column it's talking about. The relevant part of the schema is roughly this:

create table Date(
DateID int not null primary key,
/* ... */
);

create table File(
FileID int not null primary key,
FileDateID int not null foreign key references Date(DateID),
/* ... */
);

create table Fact(
/* ... */
DateID int not null foreign key references Date(DateID),
FileID int not null foreign key references File(FileID)
);

The column that's named in the error message is File.FileDateID. Note that this is not a pure snowflake schema - there's a "loop" that associates files with dates in addition to other date relationships within the main fact table. I'm just guessing that the root of the problem has something to do with non-snowflake-ness of the schema. Full processing of the database/cube works fine - it's only when I try to process incrementally or create aggregations that I get this error.

Can anyone explain what this error really means and what to do about it?Anyone?|||

Carl,

When you do the incremental processing, are you using a table as the source or a query?

Dave Fackler

|||

It was a query of the form select * from MyFactTable where SomeIncrementalCondition.

Of course, the error has gone away since I first started asking about this error a month ago. Something I changed since then "fixed" the problem (this is a product in development, so I'm constantly fiddling with the cube and dimension definitions - I have no idea which change fixed this problem, unfortunately).

Error from AS2005 - Binding for column 'xxxxx' is not a ColumnBinding type

I've seen this question come up a couple times on the public .olap newsgroup, but I've never seen an answer, so I'm going to give it another try:

I'm getting an error when I try to incrementally process my SSAS 2005 cube:

Errors in the high-level relational engine. The binding for the 'column-name' column is not a ColumnBinding type.

In this case, the column name that's given is a name that occurs in only 1 table in the underlying schema, so I know unambiguously which column it's talking about. The relevant part of the schema is roughly this:

create table Date(
DateID int not null primary key,
/* ... */
);

create table File(
FileID int not null primary key,
FileDateID int not null foreign key references Date(DateID),
/* ... */
);

create table Fact(
/* ... */
DateID int not null foreign key references Date(DateID),
FileID int not null foreign key references File(FileID)
);

The column that's named in the error message is File.FileDateID. Note that this is not a pure snowflake schema - there's a "loop" that associates files with dates in addition to other date relationships within the main fact table. I'm just guessing that the root of the problem has something to do with non-snowflake-ness of the schema. Full processing of the database/cube works fine - it's only when I try to process incrementally or create aggregations that I get this error.

Can anyone explain what this error really means and what to do about it?Anyone?|||

Carl,

When you do the incremental processing, are you using a table as the source or a query?

Dave Fackler

|||

It was a query of the form select * from MyFactTable where SomeIncrementalCondition.

Of course, the error has gone away since I first started asking about this error a month ago. Something I changed since then "fixed" the problem (this is a product in development, so I'm constantly fiddling with the cube and dimension definitions - I have no idea which change fixed this problem, unfortunately).

error for sending(saving) data to database

Hi,

I’m using VS2005 and I’m trying to link the C# windows form to MSSQL. I used BindingNavigator Control to read the data. After that I add sqlcommand and sqldataadapter to send the data to the database. My code is this

sqlDataAdapter1.InsertCommand.CommandText =

"INSERT INTO SUDENT (" +

"S_ID, S_NAME, S_ADDRESS, S_PHONE" +

") VALUES ('" +

S_IDComboBox.Text +"', '" +

S_NAMETextBox.Text +"', '" +

S_ADDRESSTextBox.Text +"', '" +

S_PHONETextBox.Text +"')";

sqlDataAdapter1.InsertCommand.ExecuteNonQuery();

It gave me this error

NulleferenceException was Unhandled”and “ Object refrence not set to an instance of an object” so I add this line

sqlCommand1 = ("INSERT INTO STUDENT (S_ID,S_NAME,S_ADDRESS,S_PHONE) VALUES (@.S_ID,@.S_NAME,@.S_ADDRESS,@.S_PHONE)" ,sqlConnection1);

Then it gave me some stupid error. By the way it didn’t make a new object of SqlCommand although I tried ….

So can u help me to solve my problem ? Thank you

the first thing i noticed is "INSERT INTO SUDENT (" +

Spelling mistake

Madhu

|||Hi,

could you please send your whole code. As of now it seems that you did not initialize the DataAdapter object.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||

Form1.designer.cs

namespace student

{

partialclassForm1

{

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.IContainer components = null;

/// <summary>

/// Clean up any resources being used.

/// </summary>

/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>

protectedoverridevoid Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

privatevoid InitializeComponent()

{

this.components = new System.ComponentModel.Container();

System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));

System.Windows.Forms.Label s_IDLabel;

System.Windows.Forms.Label s_NAMELabel;

System.Windows.Forms.Label s_ADDRESSLabel;

System.Windows.Forms.Label s_PHONELabel;

this.studentDataSet = new student.studentDataSet();

this.sTUDENTBindingSource = new System.Windows.Forms.BindingSource(this.components);

this.sTUDENTTableAdapter = new student.studentDataSetTableAdapters.STUDENTTableAdapter();

this.sTUDENTBindingNavigator = new System.Windows.Forms.BindingNavigator(this.components);

this.bindingNavigatorMoveFirstItem = new System.Windows.Forms.ToolStripButton();

this.bindingNavigatorMovePreviousItem = new System.Windows.Forms.ToolStripButton();

this.bindingNavigatorSeparator = new System.Windows.Forms.ToolStripSeparator();

this.bindingNavigatorPositionItem = new System.Windows.Forms.ToolStripTextBox();

this.bindingNavigatorCountItem = new System.Windows.Forms.ToolStripLabel();

this.bindingNavigatorSeparator1 = new System.Windows.Forms.ToolStripSeparator();

this.bindingNavigatorMoveNextItem = new System.Windows.Forms.ToolStripButton();

this.bindingNavigatorMoveLastItem = new System.Windows.Forms.ToolStripButton();

this.bindingNavigatorSeparator2 = new System.Windows.Forms.ToolStripSeparator();

this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton();

this.bindingNavigatorDeleteItem = new System.Windows.Forms.ToolStripButton();

this.sTUDENTBindingNavigatorSaveItem = new System.Windows.Forms.ToolStripButton();

this.s_IDTextBox = new System.Windows.Forms.TextBox();

this.s_NAMETextBox = new System.Windows.Forms.TextBox();

this.s_ADDRESSTextBox = new System.Windows.Forms.TextBox();

this.s_PHONETextBox = new System.Windows.Forms.TextBox();

this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();

this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();

s_IDLabel = new System.Windows.Forms.Label();

s_NAMELabel = new System.Windows.Forms.Label();

s_ADDRESSLabel = new System.Windows.Forms.Label();

s_PHONELabel = new System.Windows.Forms.Label();

((System.ComponentModel.ISupportInitialize)(this.studentDataSet)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.sTUDENTBindingSource)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.sTUDENTBindingNavigator)).BeginInit();

this.sTUDENTBindingNavigator.SuspendLayout();

this.SuspendLayout();

//

// studentDataSet

//

this.studentDataSet.DataSetName = "studentDataSet";

this.studentDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;

//

// sTUDENTBindingSource

//

this.sTUDENTBindingSource.DataMember = "STUDENT";

this.sTUDENTBindingSource.DataSource = this.studentDataSet;

//

// sTUDENTTableAdapter

//

this.sTUDENTTableAdapter.ClearBeforeFill = true;

//

// sTUDENTBindingNavigator

//

this.sTUDENTBindingNavigator.AddNewItem = this.bindingNavigatorAddNewItem;

this.sTUDENTBindingNavigator.BindingSource = this.sTUDENTBindingSource;

this.sTUDENTBindingNavigator.CountItem = this.bindingNavigatorCountItem;

this.sTUDENTBindingNavigator.DeleteItem = this.bindingNavigatorDeleteItem;

this.sTUDENTBindingNavigator.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {

this.bindingNavigatorMoveFirstItem,

this.bindingNavigatorMovePreviousItem,

this.bindingNavigatorSeparator,

this.bindingNavigatorPositionItem,

this.bindingNavigatorCountItem,

this.bindingNavigatorSeparator1,

this.bindingNavigatorMoveNextItem,

this.bindingNavigatorMoveLastItem,

this.bindingNavigatorSeparator2,

this.bindingNavigatorAddNewItem,

this.bindingNavigatorDeleteItem,

this.sTUDENTBindingNavigatorSaveItem});

this.sTUDENTBindingNavigator.Location = new System.Drawing.Point(0, 0);

this.sTUDENTBindingNavigator.MoveFirstItem = this.bindingNavigatorMoveFirstItem;

this.sTUDENTBindingNavigator.MoveLastItem = this.bindingNavigatorMoveLastItem;

this.sTUDENTBindingNavigator.MoveNextItem = this.bindingNavigatorMoveNextItem;

this.sTUDENTBindingNavigator.MovePreviousItem = this.bindingNavigatorMovePreviousItem;

this.sTUDENTBindingNavigator.Name = "sTUDENTBindingNavigator";

this.sTUDENTBindingNavigator.PositionItem = this.bindingNavigatorPositionItem;

this.sTUDENTBindingNavigator.Size = new System.Drawing.Size(463, 25);

this.sTUDENTBindingNavigator.TabIndex = 0;

this.sTUDENTBindingNavigator.Text = "bindingNavigator1";

//

// bindingNavigatorMoveFirstItem

//

this.bindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.bindingNavigatorMoveFirstItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveFirstItem.Image")));

this.bindingNavigatorMoveFirstItem.Name = "bindingNavigatorMoveFirstItem";

this.bindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = true;

this.bindingNavigatorMoveFirstItem.Size = new System.Drawing.Size(23, 22);

this.bindingNavigatorMoveFirstItem.Text = "Move first";

//

// bindingNavigatorMovePreviousItem

//

this.bindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.bindingNavigatorMovePreviousItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMovePreviousItem.Image")));

this.bindingNavigatorMovePreviousItem.Name = "bindingNavigatorMovePreviousItem";

this.bindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = true;

this.bindingNavigatorMovePreviousItem.Size = new System.Drawing.Size(23, 22);

this.bindingNavigatorMovePreviousItem.Text = "Move previous";

//

// bindingNavigatorSeparator

//

this.bindingNavigatorSeparator.Name = "bindingNavigatorSeparator";

this.bindingNavigatorSeparator.Size = new System.Drawing.Size(6, 25);

//

// bindingNavigatorPositionItem

//

this.bindingNavigatorPositionItem.AccessibleName = "Position";

this.bindingNavigatorPositionItem.AutoSize = false;

this.bindingNavigatorPositionItem.Name = "bindingNavigatorPositionItem";

this.bindingNavigatorPositionItem.Size = new System.Drawing.Size(50, 21);

this.bindingNavigatorPositionItem.Text = "0";

this.bindingNavigatorPositionItem.ToolTipText = "Current position";

//

// bindingNavigatorCountItem

//

this.bindingNavigatorCountItem.Name = "bindingNavigatorCountItem";

this.bindingNavigatorCountItem.Size = new System.Drawing.Size(36, 22);

this.bindingNavigatorCountItem.Text = "of {0}";

this.bindingNavigatorCountItem.ToolTipText = "Total number of items";

//

// bindingNavigatorSeparator1

//

this.bindingNavigatorSeparator1.Name = "bindingNavigatorSeparator";

this.bindingNavigatorSeparator1.Size = new System.Drawing.Size(6, 25);

//

// bindingNavigatorMoveNextItem

//

this.bindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.bindingNavigatorMoveNextItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveNextItem.Image")));

this.bindingNavigatorMoveNextItem.Name = "bindingNavigatorMoveNextItem";

this.bindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = true;

this.bindingNavigatorMoveNextItem.Size = new System.Drawing.Size(23, 22);

this.bindingNavigatorMoveNextItem.Text = "Move next";

//

// bindingNavigatorMoveLastItem

//

this.bindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.bindingNavigatorMoveLastItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveLastItem.Image")));

this.bindingNavigatorMoveLastItem.Name = "bindingNavigatorMoveLastItem";

this.bindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = true;

this.bindingNavigatorMoveLastItem.Size = new System.Drawing.Size(23, 22);

this.bindingNavigatorMoveLastItem.Text = "Move last";

//

// bindingNavigatorSeparator2

//

this.bindingNavigatorSeparator2.Name = "bindingNavigatorSeparator";

this.bindingNavigatorSeparator2.Size = new System.Drawing.Size(6, 25);

//

// bindingNavigatorAddNewItem

//

this.bindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.bindingNavigatorAddNewItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorAddNewItem.Image")));

this.bindingNavigatorAddNewItem.Name = "bindingNavigatorAddNewItem";

this.bindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = true;

this.bindingNavigatorAddNewItem.Size = new System.Drawing.Size(23, 22);

this.bindingNavigatorAddNewItem.Text = "Add new";

//

// bindingNavigatorDeleteItem

//

this.bindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.bindingNavigatorDeleteItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorDeleteItem.Image")));

this.bindingNavigatorDeleteItem.Name = "bindingNavigatorDeleteItem";

this.bindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = true;

this.bindingNavigatorDeleteItem.Size = new System.Drawing.Size(23, 22);

this.bindingNavigatorDeleteItem.Text = "Delete";

//

// sTUDENTBindingNavigatorSaveItem

//

this.sTUDENTBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.sTUDENTBindingNavigatorSaveItem.Image = ((System.Drawing.Image)(resources.GetObject("sTUDENTBindingNavigatorSaveItem.Image")));

this.sTUDENTBindingNavigatorSaveItem.Name = "sTUDENTBindingNavigatorSaveItem";

this.sTUDENTBindingNavigatorSaveItem.Size = new System.Drawing.Size(23, 22);

this.sTUDENTBindingNavigatorSaveItem.Text = "Save Data";

this.sTUDENTBindingNavigatorSaveItem.Click += new System.EventHandler(this.sTUDENTBindingNavigatorSaveItem_Click);

//

// s_IDLabel

//

s_IDLabel.AutoSize = true;

s_IDLabel.Location = new System.Drawing.Point(44, 52);

s_IDLabel.Name = "s_IDLabel";

s_IDLabel.Size = new System.Drawing.Size(31, 13);

s_IDLabel.TabIndex = 1;

s_IDLabel.Text = "S ID:";

//

// s_IDTextBox

//

this.s_IDTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.sTUDENTBindingSource, "S_ID", true));

this.s_IDTextBox.Location = new System.Drawing.Point(81, 49);

this.s_IDTextBox.Name = "s_IDTextBox";

this.s_IDTextBox.Size = new System.Drawing.Size(100, 20);

this.s_IDTextBox.TabIndex = 2;

//

// s_NAMELabel

//

s_NAMELabel.AutoSize = true;

s_NAMELabel.Location = new System.Drawing.Point(51, 91);

s_NAMELabel.Name = "s_NAMELabel";

s_NAMELabel.Size = new System.Drawing.Size(51, 13);

s_NAMELabel.TabIndex = 3;

s_NAMELabel.Text = "S NAME:";

//

// s_NAMETextBox

//

this.s_NAMETextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.sTUDENTBindingSource, "S_NAME", true));

this.s_NAMETextBox.Location = new System.Drawing.Point(108, 88);

this.s_NAMETextBox.Name = "s_NAMETextBox";

this.s_NAMETextBox.Size = new System.Drawing.Size(100, 20);

this.s_NAMETextBox.TabIndex = 4;

//

// s_ADDRESSLabel

//

s_ADDRESSLabel.AutoSize = true;

s_ADDRESSLabel.Location = new System.Drawing.Point(49, 122);

s_ADDRESSLabel.Name = "s_ADDRESSLabel";

s_ADDRESSLabel.Size = new System.Drawing.Size(72, 13);

s_ADDRESSLabel.TabIndex = 5;

s_ADDRESSLabel.Text = "S ADDRESS:";

//

// s_ADDRESSTextBox

//

this.s_ADDRESSTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.sTUDENTBindingSource, "S_ADDRESS", true));

this.s_ADDRESSTextBox.Location = new System.Drawing.Point(127, 119);

this.s_ADDRESSTextBox.Name = "s_ADDRESSTextBox";

this.s_ADDRESSTextBox.Size = new System.Drawing.Size(100, 20);

this.s_ADDRESSTextBox.TabIndex = 6;

//

// s_PHONELabel

//

s_PHONELabel.AutoSize = true;

s_PHONELabel.Location = new System.Drawing.Point(77, 160);

s_PHONELabel.Name = "s_PHONELabel";

s_PHONELabel.Size = new System.Drawing.Size(58, 13);

s_PHONELabel.TabIndex = 7;

s_PHONELabel.Text = "S PHONE:";

//

// s_PHONETextBox

//

this.s_PHONETextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.sTUDENTBindingSource, "S_PHONE", true));

this.s_PHONETextBox.Location = new System.Drawing.Point(141, 157);

this.s_PHONETextBox.Name = "s_PHONETextBox";

this.s_PHONETextBox.Size = new System.Drawing.Size(100, 20);

this.s_PHONETextBox.TabIndex = 8;

//

// sqlConnection1

//

this.sqlConnection1.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=\"C:\\Documents and Settings\\Glad\\Desktop" +

"\\student\\student\\student.mdf\";Integrated Security=True;User Instance=True";

this.sqlConnection1.FireInfoMessageEventOnUserErrors = true;

this.sqlConnection1.StatisticsEnabled = true;

//

// sqlCommand1

//

this.sqlCommand1.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {

new System.Data.SqlClient.SqlParameter("@.S_ID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Output, false, ((byte)(0)), ((byte)(0)), "", System.Data.DataRowVersion.Current, null),

new System.Data.SqlClient.SqlParameter("@.S_NAME", System.Data.SqlDbType.VarChar),

new System.Data.SqlClient.SqlParameter("@.S_ADDRESS", System.Data.SqlDbType.VarChar),

new System.Data.SqlClient.SqlParameter("@.S_PHONE", System.Data.SqlDbType.Text)});

//

// sqlSelectCommand1

//

this.sqlSelectCommand1.CommandText = "SELECT S_ID, S_NAME, S_ADDRESS, S_PHONE\r\nFROM STUDENT";

this.sqlSelectCommand1.Connection = this.sqlConnection1;

//

// sqlInsertCommand1

//

this.sqlInsertCommand1.CommandText = "INSERT INTO [STUDENT] ([S_ID], [S_NAME], [S_ADDRESS], [S_PHONE]) VALUES (@.S_ID, @." +

"S_NAME, @.S_ADDRESS, @.S_PHONE)";

this.sqlInsertCommand1.Connection = this.sqlConnection1;

this.sqlInsertCommand1.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {

new System.Data.SqlClient.SqlParameter("@.S_ID", System.Data.SqlDbType.Int, 0, "S_ID"),

new System.Data.SqlClient.SqlParameter("@.S_NAME", System.Data.SqlDbType.VarChar, 0, "S_NAME"),

new System.Data.SqlClient.SqlParameter("@.S_ADDRESS", System.Data.SqlDbType.VarChar, 0, "S_ADDRESS"),

new System.Data.SqlClient.SqlParameter("@.S_PHONE", System.Data.SqlDbType.Text, 0, "S_PHONE")});

//

// sqlDataAdapter1

//

this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;

this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;

this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {

new System.Data.Common.DataTableMapping("Table", "STUDENT", new System.Data.Common.DataColumnMapping[] {

new System.Data.Common.DataColumnMapping("S_ID", "S_ID"),

new System.Data.Common.DataColumnMapping("S_NAME", "S_NAME"),

new System.Data.Common.DataColumnMapping("S_ADDRESS", "S_ADDRESS"),

new System.Data.Common.DataColumnMapping("S_PHONE", "S_PHONE")})});

//

// Form1

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(463, 266);

this.Controls.Add(s_PHONELabel);

this.Controls.Add(this.s_PHONETextBox);

this.Controls.Add(s_ADDRESSLabel);

this.Controls.Add(this.s_ADDRESSTextBox);

this.Controls.Add(s_NAMELabel);

this.Controls.Add(this.s_NAMETextBox);

this.Controls.Add(s_IDLabel);

this.Controls.Add(this.s_IDTextBox);

this.Controls.Add(this.sTUDENTBindingNavigator);

this.Name = "Form1";

this.Text = "Form1";

this.Load += new System.EventHandler(this.Form1_Load);

((System.ComponentModel.ISupportInitialize)(this.studentDataSet)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.sTUDENTBindingSource)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.sTUDENTBindingNavigator)).EndInit();

this.sTUDENTBindingNavigator.ResumeLayout(false);

this.sTUDENTBindingNavigator.PerformLayout();

this.ResumeLayout(false);

this.PerformLayout();

}

#endregion

privatestudentDataSet studentDataSet;

private System.Windows.Forms.BindingSource sTUDENTBindingSource;

private student.studentDataSetTableAdapters.STUDENTTableAdapter sTUDENTTableAdapter;

private System.Windows.Forms.BindingNavigator sTUDENTBindingNavigator;

private System.Windows.Forms.ToolStripButton bindingNavigatorAddNewItem;

private System.Windows.Forms.ToolStripLabel bindingNavigatorCountItem;

private System.Windows.Forms.ToolStripButton bindingNavigatorDeleteItem;

private System.Windows.Forms.ToolStripButton bindingNavigatorMoveFirstItem;

private System.Windows.Forms.ToolStripButton bindingNavigatorMovePreviousItem;

private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator;

private System.Windows.Forms.ToolStripTextBox bindingNavigatorPositionItem;

private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator1;

private System.Windows.Forms.ToolStripButton bindingNavigatorMoveNextItem;

private System.Windows.Forms.ToolStripButton bindingNavigatorMoveLastItem;

private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator2;

private System.Windows.Forms.ToolStripButton sTUDENTBindingNavigatorSaveItem;

private System.Windows.Forms.TextBox s_IDTextBox;

private System.Windows.Forms.TextBox s_NAMETextBox;

private System.Windows.Forms.TextBox s_ADDRESSTextBox;

private System.Windows.Forms.TextBox s_PHONETextBox;

private System.Data.SqlClient.SqlConnection sqlConnection1;

private System.Data.SqlClient.SqlCommand sqlCommand1;

private System.Data.SqlClient.SqlCommand sqlSelectCommand1;

private System.Data.SqlClient.SqlCommand sqlInsertCommand1;

private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;

}

}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

form1.cs

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace student

{

publicpartialclassForm1 : Form

{

public Form1()

{

InitializeComponent();

}

privatevoid sTUDENTBindingNavigatorSaveItem_Click(object sender, EventArgs e)

{

sqlConnection1.Open();

sqlDataAdapter1.InsertCommand.CommandText=

"INSERT INTO STUDENT (" +

"S_ID, S_NAME, S_ADDRESS, S_PHONE" +

") VALUES ('" +

s_IDTextBox.Text + "', '" +

s_NAMETextBox.Text + "', '" +

s_ADDRESSTextBox.Text + "', '" +

s_PHONETextBox.Text + "')";

sqlDataAdapter1.InsertCommand.ExecuteNonQuery();

sqlConnection1.Close();

this.Validate();

this.sTUDENTBindingSource.EndEdit();

this.sTUDENTTableAdapter.Update(this.studentDataSet.STUDENT);

}

privatevoid Form1_Load(object sender, EventArgs e)

{

this.sTUDENTTableAdapter.Fill(this.studentDataSet.STUDENT);

}

}

}

|||Does the problem still exist ?

Jens K. Suessmeyer.

http://www.sqlserver2005.de

error for sending(saving) data to database

Hi,

I’m using VS2005 and I’m trying to link the C# windows form to MSSQL. I used BindingNavigator Control to read the data. After that I add sqlcommand and sqldataadapter to send the data to the database. My code is this

sqlDataAdapter1.InsertCommand.CommandText =

"INSERT INTO SUDENT (" +

"S_ID, S_NAME, S_ADDRESS, S_PHONE" +

") VALUES ('" +

S_IDComboBox.Text + "', '" +

S_NAMETextBox.Text + "', '" +

S_ADDRESSTextBox.Text + "', '" +

S_PHONETextBox.Text + "')";

sqlDataAdapter1.InsertCommand.ExecuteNonQuery();

It gave me this error

NulleferenceException was Unhandled”and “ Object refrence not set to an instance of an object” so I add this line

sqlCommand1 = ("INSERT INTO STUDENT (S_ID,S_NAME,S_ADDRESS,S_PHONE) VALUES (@.S_ID,@.S_NAME,@.S_ADDRESS,@.S_PHONE)" ,sqlConnection1);

Then it gave me some stupid error. By the way it didn’t make a new object of SqlCommand although I tried ….

So can u help me to solve my problem ? Thank you

the first thing i noticed is "INSERT INTO SUDENT (" +

Spelling mistake

Madhu

|||Hi,

could you please send your whole code. As of now it seems that you did not initialize the DataAdapter object.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||

Form1.designer.cs

namespace student

{

partial class Form1

{

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.IContainer components = null;

/// <summary>

/// Clean up any resources being used.

/// </summary>

/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));

System.Windows.Forms.Label s_IDLabel;

System.Windows.Forms.Label s_NAMELabel;

System.Windows.Forms.Label s_ADDRESSLabel;

System.Windows.Forms.Label s_PHONELabel;

this.studentDataSet = new student.studentDataSet();

this.sTUDENTBindingSource = new System.Windows.Forms.BindingSource(this.components);

this.sTUDENTTableAdapter = new student.studentDataSetTableAdapters.STUDENTTableAdapter();

this.sTUDENTBindingNavigator = new System.Windows.Forms.BindingNavigator(this.components);

this.bindingNavigatorMoveFirstItem = new System.Windows.Forms.ToolStripButton();

this.bindingNavigatorMovePreviousItem = new System.Windows.Forms.ToolStripButton();

this.bindingNavigatorSeparator = new System.Windows.Forms.ToolStripSeparator();

this.bindingNavigatorPositionItem = new System.Windows.Forms.ToolStripTextBox();

this.bindingNavigatorCountItem = new System.Windows.Forms.ToolStripLabel();

this.bindingNavigatorSeparator1 = new System.Windows.Forms.ToolStripSeparator();

this.bindingNavigatorMoveNextItem = new System.Windows.Forms.ToolStripButton();

this.bindingNavigatorMoveLastItem = new System.Windows.Forms.ToolStripButton();

this.bindingNavigatorSeparator2 = new System.Windows.Forms.ToolStripSeparator();

this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton();

this.bindingNavigatorDeleteItem = new System.Windows.Forms.ToolStripButton();

this.sTUDENTBindingNavigatorSaveItem = new System.Windows.Forms.ToolStripButton();

this.s_IDTextBox = new System.Windows.Forms.TextBox();

this.s_NAMETextBox = new System.Windows.Forms.TextBox();

this.s_ADDRESSTextBox = new System.Windows.Forms.TextBox();

this.s_PHONETextBox = new System.Windows.Forms.TextBox();

this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();

this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();

this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();

s_IDLabel = new System.Windows.Forms.Label();

s_NAMELabel = new System.Windows.Forms.Label();

s_ADDRESSLabel = new System.Windows.Forms.Label();

s_PHONELabel = new System.Windows.Forms.Label();

((System.ComponentModel.ISupportInitialize)(this.studentDataSet)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.sTUDENTBindingSource)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.sTUDENTBindingNavigator)).BeginInit();

this.sTUDENTBindingNavigator.SuspendLayout();

this.SuspendLayout();

//

// studentDataSet

//

this.studentDataSet.DataSetName = "studentDataSet";

this.studentDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;

//

// sTUDENTBindingSource

//

this.sTUDENTBindingSource.DataMember = "STUDENT";

this.sTUDENTBindingSource.DataSource = this.studentDataSet;

//

// sTUDENTTableAdapter

//

this.sTUDENTTableAdapter.ClearBeforeFill = true;

//

// sTUDENTBindingNavigator

//

this.sTUDENTBindingNavigator.AddNewItem = this.bindingNavigatorAddNewItem;

this.sTUDENTBindingNavigator.BindingSource = this.sTUDENTBindingSource;

this.sTUDENTBindingNavigator.CountItem = this.bindingNavigatorCountItem;

this.sTUDENTBindingNavigator.DeleteItem = this.bindingNavigatorDeleteItem;

this.sTUDENTBindingNavigator.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {

this.bindingNavigatorMoveFirstItem,

this.bindingNavigatorMovePreviousItem,

this.bindingNavigatorSeparator,

this.bindingNavigatorPositionItem,

this.bindingNavigatorCountItem,

this.bindingNavigatorSeparator1,

this.bindingNavigatorMoveNextItem,

this.bindingNavigatorMoveLastItem,

this.bindingNavigatorSeparator2,

this.bindingNavigatorAddNewItem,

this.bindingNavigatorDeleteItem,

this.sTUDENTBindingNavigatorSaveItem});

this.sTUDENTBindingNavigator.Location = new System.Drawing.Point(0, 0);

this.sTUDENTBindingNavigator.MoveFirstItem = this.bindingNavigatorMoveFirstItem;

this.sTUDENTBindingNavigator.MoveLastItem = this.bindingNavigatorMoveLastItem;

this.sTUDENTBindingNavigator.MoveNextItem = this.bindingNavigatorMoveNextItem;

this.sTUDENTBindingNavigator.MovePreviousItem = this.bindingNavigatorMovePreviousItem;

this.sTUDENTBindingNavigator.Name = "sTUDENTBindingNavigator";

this.sTUDENTBindingNavigator.PositionItem = this.bindingNavigatorPositionItem;

this.sTUDENTBindingNavigator.Size = new System.Drawing.Size(463, 25);

this.sTUDENTBindingNavigator.TabIndex = 0;

this.sTUDENTBindingNavigator.Text = "bindingNavigator1";

//

// bindingNavigatorMoveFirstItem

//

this.bindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.bindingNavigatorMoveFirstItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveFirstItem.Image")));

this.bindingNavigatorMoveFirstItem.Name = "bindingNavigatorMoveFirstItem";

this.bindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = true;

this.bindingNavigatorMoveFirstItem.Size = new System.Drawing.Size(23, 22);

this.bindingNavigatorMoveFirstItem.Text = "Move first";

//

// bindingNavigatorMovePreviousItem

//

this.bindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.bindingNavigatorMovePreviousItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMovePreviousItem.Image")));

this.bindingNavigatorMovePreviousItem.Name = "bindingNavigatorMovePreviousItem";

this.bindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = true;

this.bindingNavigatorMovePreviousItem.Size = new System.Drawing.Size(23, 22);

this.bindingNavigatorMovePreviousItem.Text = "Move previous";

//

// bindingNavigatorSeparator

//

this.bindingNavigatorSeparator.Name = "bindingNavigatorSeparator";

this.bindingNavigatorSeparator.Size = new System.Drawing.Size(6, 25);

//

// bindingNavigatorPositionItem

//

this.bindingNavigatorPositionItem.AccessibleName = "Position";

this.bindingNavigatorPositionItem.AutoSize = false;

this.bindingNavigatorPositionItem.Name = "bindingNavigatorPositionItem";

this.bindingNavigatorPositionItem.Size = new System.Drawing.Size(50, 21);

this.bindingNavigatorPositionItem.Text = "0";

this.bindingNavigatorPositionItem.ToolTipText = "Current position";

//

// bindingNavigatorCountItem

//

this.bindingNavigatorCountItem.Name = "bindingNavigatorCountItem";

this.bindingNavigatorCountItem.Size = new System.Drawing.Size(36, 22);

this.bindingNavigatorCountItem.Text = "of {0}";

this.bindingNavigatorCountItem.ToolTipText = "Total number of items";

//

// bindingNavigatorSeparator1

//

this.bindingNavigatorSeparator1.Name = "bindingNavigatorSeparator";

this.bindingNavigatorSeparator1.Size = new System.Drawing.Size(6, 25);

//

// bindingNavigatorMoveNextItem

//

this.bindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.bindingNavigatorMoveNextItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveNextItem.Image")));

this.bindingNavigatorMoveNextItem.Name = "bindingNavigatorMoveNextItem";

this.bindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = true;

this.bindingNavigatorMoveNextItem.Size = new System.Drawing.Size(23, 22);

this.bindingNavigatorMoveNextItem.Text = "Move next";

//

// bindingNavigatorMoveLastItem

//

this.bindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.bindingNavigatorMoveLastItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveLastItem.Image")));

this.bindingNavigatorMoveLastItem.Name = "bindingNavigatorMoveLastItem";

this.bindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = true;

this.bindingNavigatorMoveLastItem.Size = new System.Drawing.Size(23, 22);

this.bindingNavigatorMoveLastItem.Text = "Move last";

//

// bindingNavigatorSeparator2

//

this.bindingNavigatorSeparator2.Name = "bindingNavigatorSeparator";

this.bindingNavigatorSeparator2.Size = new System.Drawing.Size(6, 25);

//

// bindingNavigatorAddNewItem

//

this.bindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.bindingNavigatorAddNewItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorAddNewItem.Image")));

this.bindingNavigatorAddNewItem.Name = "bindingNavigatorAddNewItem";

this.bindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = true;

this.bindingNavigatorAddNewItem.Size = new System.Drawing.Size(23, 22);

this.bindingNavigatorAddNewItem.Text = "Add new";

//

// bindingNavigatorDeleteItem

//

this.bindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.bindingNavigatorDeleteItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorDeleteItem.Image")));

this.bindingNavigatorDeleteItem.Name = "bindingNavigatorDeleteItem";

this.bindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = true;

this.bindingNavigatorDeleteItem.Size = new System.Drawing.Size(23, 22);

this.bindingNavigatorDeleteItem.Text = "Delete";

//

// sTUDENTBindingNavigatorSaveItem

//

this.sTUDENTBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;

this.sTUDENTBindingNavigatorSaveItem.Image = ((System.Drawing.Image)(resources.GetObject("sTUDENTBindingNavigatorSaveItem.Image")));

this.sTUDENTBindingNavigatorSaveItem.Name = "sTUDENTBindingNavigatorSaveItem";

this.sTUDENTBindingNavigatorSaveItem.Size = new System.Drawing.Size(23, 22);

this.sTUDENTBindingNavigatorSaveItem.Text = "Save Data";

this.sTUDENTBindingNavigatorSaveItem.Click += new System.EventHandler(this.sTUDENTBindingNavigatorSaveItem_Click);

//

// s_IDLabel

//

s_IDLabel.AutoSize = true;

s_IDLabel.Location = new System.Drawing.Point(44, 52);

s_IDLabel.Name = "s_IDLabel";

s_IDLabel.Size = new System.Drawing.Size(31, 13);

s_IDLabel.TabIndex = 1;

s_IDLabel.Text = "S ID:";

//

// s_IDTextBox

//

this.s_IDTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.sTUDENTBindingSource, "S_ID", true));

this.s_IDTextBox.Location = new System.Drawing.Point(81, 49);

this.s_IDTextBox.Name = "s_IDTextBox";

this.s_IDTextBox.Size = new System.Drawing.Size(100, 20);

this.s_IDTextBox.TabIndex = 2;

//

// s_NAMELabel

//

s_NAMELabel.AutoSize = true;

s_NAMELabel.Location = new System.Drawing.Point(51, 91);

s_NAMELabel.Name = "s_NAMELabel";

s_NAMELabel.Size = new System.Drawing.Size(51, 13);

s_NAMELabel.TabIndex = 3;

s_NAMELabel.Text = "S NAME:";

//

// s_NAMETextBox

//

this.s_NAMETextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.sTUDENTBindingSource, "S_NAME", true));

this.s_NAMETextBox.Location = new System.Drawing.Point(108, 88);

this.s_NAMETextBox.Name = "s_NAMETextBox";

this.s_NAMETextBox.Size = new System.Drawing.Size(100, 20);

this.s_NAMETextBox.TabIndex = 4;

//

// s_ADDRESSLabel

//

s_ADDRESSLabel.AutoSize = true;

s_ADDRESSLabel.Location = new System.Drawing.Point(49, 122);

s_ADDRESSLabel.Name = "s_ADDRESSLabel";

s_ADDRESSLabel.Size = new System.Drawing.Size(72, 13);

s_ADDRESSLabel.TabIndex = 5;

s_ADDRESSLabel.Text = "S ADDRESS:";

//

// s_ADDRESSTextBox

//

this.s_ADDRESSTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.sTUDENTBindingSource, "S_ADDRESS", true));

this.s_ADDRESSTextBox.Location = new System.Drawing.Point(127, 119);

this.s_ADDRESSTextBox.Name = "s_ADDRESSTextBox";

this.s_ADDRESSTextBox.Size = new System.Drawing.Size(100, 20);

this.s_ADDRESSTextBox.TabIndex = 6;

//

// s_PHONELabel

//

s_PHONELabel.AutoSize = true;

s_PHONELabel.Location = new System.Drawing.Point(77, 160);

s_PHONELabel.Name = "s_PHONELabel";

s_PHONELabel.Size = new System.Drawing.Size(58, 13);

s_PHONELabel.TabIndex = 7;

s_PHONELabel.Text = "S PHONE:";

//

// s_PHONETextBox

//

this.s_PHONETextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.sTUDENTBindingSource, "S_PHONE", true));

this.s_PHONETextBox.Location = new System.Drawing.Point(141, 157);

this.s_PHONETextBox.Name = "s_PHONETextBox";

this.s_PHONETextBox.Size = new System.Drawing.Size(100, 20);

this.s_PHONETextBox.TabIndex = 8;

//

// sqlConnection1

//

this.sqlConnection1.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=\"C:\\Documents and Settings\\Glad\\Desktop" +

"\\student\\student\\student.mdf\";Integrated Security=True;User Instance=True";

this.sqlConnection1.FireInfoMessageEventOnUserErrors = true;

this.sqlConnection1.StatisticsEnabled = true;

//

// sqlCommand1

//

this.sqlCommand1.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {

new System.Data.SqlClient.SqlParameter("@.S_ID", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Output, false, ((byte)(0)), ((byte)(0)), "", System.Data.DataRowVersion.Current, null),

new System.Data.SqlClient.SqlParameter("@.S_NAME", System.Data.SqlDbType.VarChar),

new System.Data.SqlClient.SqlParameter("@.S_ADDRESS", System.Data.SqlDbType.VarChar),

new System.Data.SqlClient.SqlParameter("@.S_PHONE", System.Data.SqlDbType.Text)});

//

// sqlSelectCommand1

//

this.sqlSelectCommand1.CommandText = "SELECT S_ID, S_NAME, S_ADDRESS, S_PHONE\r\nFROM STUDENT";

this.sqlSelectCommand1.Connection = this.sqlConnection1;

//

// sqlInsertCommand1

//

this.sqlInsertCommand1.CommandText = "INSERT INTO [STUDENT] ([S_ID], [S_NAME], [S_ADDRESS], [S_PHONE]) VALUES (@.S_ID, @." +

"S_NAME, @.S_ADDRESS, @.S_PHONE)";

this.sqlInsertCommand1.Connection = this.sqlConnection1;

this.sqlInsertCommand1.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {

new System.Data.SqlClient.SqlParameter("@.S_ID", System.Data.SqlDbType.Int, 0, "S_ID"),

new System.Data.SqlClient.SqlParameter("@.S_NAME", System.Data.SqlDbType.VarChar, 0, "S_NAME"),

new System.Data.SqlClient.SqlParameter("@.S_ADDRESS", System.Data.SqlDbType.VarChar, 0, "S_ADDRESS"),

new System.Data.SqlClient.SqlParameter("@.S_PHONE", System.Data.SqlDbType.Text, 0, "S_PHONE")});

//

// sqlDataAdapter1

//

this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;

this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;

this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {

new System.Data.Common.DataTableMapping("Table", "STUDENT", new System.Data.Common.DataColumnMapping[] {

new System.Data.Common.DataColumnMapping("S_ID", "S_ID"),

new System.Data.Common.DataColumnMapping("S_NAME", "S_NAME"),

new System.Data.Common.DataColumnMapping("S_ADDRESS", "S_ADDRESS"),

new System.Data.Common.DataColumnMapping("S_PHONE", "S_PHONE")})});

//

// Form1

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(463, 266);

this.Controls.Add(s_PHONELabel);

this.Controls.Add(this.s_PHONETextBox);

this.Controls.Add(s_ADDRESSLabel);

this.Controls.Add(this.s_ADDRESSTextBox);

this.Controls.Add(s_NAMELabel);

this.Controls.Add(this.s_NAMETextBox);

this.Controls.Add(s_IDLabel);

this.Controls.Add(this.s_IDTextBox);

this.Controls.Add(this.sTUDENTBindingNavigator);

this.Name = "Form1";

this.Text = "Form1";

this.Load += new System.EventHandler(this.Form1_Load);

((System.ComponentModel.ISupportInitialize)(this.studentDataSet)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.sTUDENTBindingSource)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.sTUDENTBindingNavigator)).EndInit();

this.sTUDENTBindingNavigator.ResumeLayout(false);

this.sTUDENTBindingNavigator.PerformLayout();

this.ResumeLayout(false);

this.PerformLayout();

}

#endregion

private studentDataSet studentDataSet;

private System.Windows.Forms.BindingSource sTUDENTBindingSource;

private student.studentDataSetTableAdapters.STUDENTTableAdapter sTUDENTTableAdapter;

private System.Windows.Forms.BindingNavigator sTUDENTBindingNavigator;

private System.Windows.Forms.ToolStripButton bindingNavigatorAddNewItem;

private System.Windows.Forms.ToolStripLabel bindingNavigatorCountItem;

private System.Windows.Forms.ToolStripButton bindingNavigatorDeleteItem;

private System.Windows.Forms.ToolStripButton bindingNavigatorMoveFirstItem;

private System.Windows.Forms.ToolStripButton bindingNavigatorMovePreviousItem;

private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator;

private System.Windows.Forms.ToolStripTextBox bindingNavigatorPositionItem;

private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator1;

private System.Windows.Forms.ToolStripButton bindingNavigatorMoveNextItem;

private System.Windows.Forms.ToolStripButton bindingNavigatorMoveLastItem;

private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator2;

private System.Windows.Forms.ToolStripButton sTUDENTBindingNavigatorSaveItem;

private System.Windows.Forms.TextBox s_IDTextBox;

private System.Windows.Forms.TextBox s_NAMETextBox;

private System.Windows.Forms.TextBox s_ADDRESSTextBox;

private System.Windows.Forms.TextBox s_PHONETextBox;

private System.Data.SqlClient.SqlConnection sqlConnection1;

private System.Data.SqlClient.SqlCommand sqlCommand1;

private System.Data.SqlClient.SqlCommand sqlSelectCommand1;

private System.Data.SqlClient.SqlCommand sqlInsertCommand1;

private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;

}

}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

form1.cs

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace student

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void sTUDENTBindingNavigatorSaveItem_Click(object sender, EventArgs e)

{

sqlConnection1.Open();

sqlDataAdapter1.InsertCommand.CommandText=

"INSERT INTO STUDENT (" +

"S_ID, S_NAME, S_ADDRESS, S_PHONE" +

") VALUES ('" +

s_IDTextBox.Text + "', '" +

s_NAMETextBox.Text + "', '" +

s_ADDRESSTextBox.Text + "', '" +

s_PHONETextBox.Text + "')";

sqlDataAdapter1.InsertCommand.ExecuteNonQuery();

sqlConnection1.Close();

this.Validate();

this.sTUDENTBindingSource.EndEdit();

this.sTUDENTTableAdapter.Update(this.studentDataSet.STUDENT);

}

private void Form1_Load(object sender, EventArgs e)

{

this.sTUDENTTableAdapter.Fill(this.studentDataSet.STUDENT);

}

}

}

|||Does the problem still exist ?

Jens K. Suessmeyer.

http://www.sqlserver2005.de