Connecting to database

C

cameljs18

Please help! I have a table in the database with two columns set to
float.Now when i try to write to this table it executes perfect but
the values in the database dont change i have no idea what it could
be.Here is my code

private void button450Save_Click(object sender, EventArgs e)
{
SqlCommand Adapt450 = new SqlCommand("update op450set set
Min_Torque = 4.5,Max_Torque = 6.8", sqlConnection1);
sqlConnection1.Open();
Adapt450.ExecuteNonQuery();
sqlConnection1.Close();
}

Its simple code should work i have tested it in sqlmanager and it
works and my connection string is fine.Any suggestions??? thanks
 
A

Alberto Poblacion

Please help! I have a table in the database with two columns set to
float.Now when i try to write to this table it executes perfect but
the values in the database dont change i have no idea what it could
be.Here is my code

private void button450Save_Click(object sender, EventArgs e)
{
SqlCommand Adapt450 = new SqlCommand("update op450set set
Min_Torque = 4.5,Max_Torque = 6.8", sqlConnection1);
sqlConnection1.Open();
Adapt450.ExecuteNonQuery();
sqlConnection1.Close();
}

Its simple code should work i have tested it in sqlmanager and it
works and my connection string is fine.Any suggestions??? thanks

Do you happen to be running this under Visual Studio 2005, using Sql
Server Express with the database in "user instance" mode? The default
configuration, if you have not changed it, copies your database from the
source code folder into the runtime folder and runs the query against the
copy. The copy is overwritten from the original every time you re-run the
program, so you won't see the changes either in the original database or in
the copy if you run the program for a second time.
 
C

cameljs18

Here is the code for the table
USE [Visteon]
GO
/****** Object: Table [dbo].[OP450Set] Script Date: 01/15/2008
09:46:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OP450Set](
[Transkey] [smallint] IDENTITY(1,1) NOT NULL,
[Min_Torque] [float] NULL,
[Max_Torque] [float] NULL
) ON [PRIMARY]
 
A

Alberto Poblacion

Here is the code for the table

Nothing wrong with the table. If the problem is what I hinted in a
previous message, your trouble is much higher than table-level: it's the
database server itself, along with the database file. Take a look at your
ConnectionString, and see whether you are working with a User Instance, and
in that case, what is your AttachDbFilename. Then verify that when you are
examining your table to see if the changes were successful, you are looking
at the *same* .mdf, not at another copy.
 
P

Peter Bromberg [C# MVP]

private void button450Save_Click(object sender, EventArgs e)
{
try{
SqlCommand Adapt450 = new SqlCommand("update op450set set
Min_Torque = 4.5,Max_Torque = 6.8", sqlConnection1);
sqlConnection1.Open();
Adapt450.ExecuteNonQuery();
}
catch(SqlException sqlex)
{
// put a breakpoint on next line so you can see what went wrong
System.Diagnostics.Debug.WriteLine( sqlex.ToString() )
}
finally
{
sqlConnection1.Close();
}
}

// the above pattern should prove quite useful during development.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
 
C

cameljs18

private void button450Save_Click(object sender, EventArgs e)
{
try{
SqlCommand Adapt450 = new SqlCommand("update op450set set
Min_Torque = 4.5,Max_Torque = 6.8", sqlConnection1);
sqlConnection1.Open();
Adapt450.ExecuteNonQuery();
}
catch(SqlException sqlex)
{
// put a breakpoint on next line so you can see what went wrong
System.Diagnostics.Debug.WriteLine( sqlex.ToString() )
}
finally
{
sqlConnection1.Close();
}
}

// the above pattern should prove quite useful during development.
-- Peter
Site:http://www.eggheadcafe.com
UnBlog:http://petesbloggerama.blogspot.com
MetaFinder:http://www.blogmetafinder.com

Thanks got it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top