ExecuteNonQuery returns 1 , Database wont Update
hello i am creating a Windows Application
C# 3.5
when i executeing function to insert into SQL Epxress
it returns 1 on the Rows Effect but checking the Database Data nothing is inserted.
public int ExectueNonQuery(string command)
{
int Results = -1;
try
{
connection = new SqlConnection(ConnectionString);
connection.Open();
scommand = new SqlCommand(command, connection);
Results = scommand.ExecuteNonQuery();
}
finally
{
scommand.Dispose();
if (connection != null)
connection.Close();
}
return Results;
}
Itzik SPosted Jun 11, 2009, 6:26 PM
Itzik SPosted Jun 23, 2009, 2:45 PM
CoryPosted Jun 23, 2009, 2:00 PM
Itzik SPosted Jun 23, 2009, 1:43 PM
CoryPosted Jun 23, 2009, 1:29 PM
So, I have stored my database at C:\Test\ProjectInfo.mdf -- what other steps will I need to take?
Would my connection string simply be the file path? Do I have to add that localized database (Project --> Add Existing Item...) into my project from within visual studio? I have tried a few different things and keep getting an error when I attempt to open a connection to that localized database.
Itzik SPosted Jun 23, 2009, 11:38 AM
CoryPosted Jun 23, 2009, 11:27 AM
You said the problem was with your "DB Location"; could you please elaborate? What exactly was the problem with your DB location? Did you need to alter the connection string, or a database property, or anything else?
In short, what problem did you find with your DB Location, and how did you correct the issue? Thanks!