I am trying to write to a database table using native configuration.
I have already checked my connection string, I believe I am connecting.
However, I get the "table3 is invalid object " error.
I checked the spelling and case of my objects. These objects exist.
Why do I get this error

invalid object
Szymon Kobalczyk
I can't really tell, without seeing your source code :-)
bodalal
Hi,
from what i understand, if ExecuteNonQuery() is producing an error, then either the table name is wrong, the column name is wrong or there is a syntax error in some clause.
use the following syntax..
string insertString = @"INSERT INTO table3(nodenames2) VALUES('"+ndeText+"')";
im assuming that table name is table3 and columname is nodenames2 (make sure of the case, i think these are case-sensitive.)
secondly.... in the VALUES clause... the syntax is...
VALUES('value1','value2')
Here values are enclosed in single quotes.
Im pretty sure that will help, still if it doesnt,
try using the TRY CATCH block with executenonquery() method...
try { cmd.ExecuteNonQuery() }
catch (SqlException e)
{
string errorMessages = "";
for (int i=0; i < e.Errors.Count; i++)
{
errorMessages += "Index #" + i + "\n" +
"Message: " + e.Errors[ i].Message + "\n" +
"LineNumber: " + e.Errors[ i].LineNumber + "\n" +
"Source: " + e.Errors[ i].Source + "\n" +
"Procedure: " + e.Errors[ i].Procedure + "\n";
}
System.Console.WriteLine(errorMessages);
}
Something like this to actaullly track down the error. Maybe if u can post the error anyone here can help.
(and a note if any1 can help, the index operator when used [ i ] without spaces prints lil bulbs :p.... )
Zaki.
Mostafa Omar
OK, in that case, feel free to send me the project, as I offered. What you're describing makes no sense at all, there's little chance that anyone will work out the problem without being able to look through the whole project.
Chris Duxbury
Tried with a literal string too.
Remember, the error was "invalid object table3".
t
zz1
You do not specify what database to use in the querystring. If the user running the app does not have that database as default database it will work in master database and it probably does not contain table3.
SqlConnection conn = new SqlConnection("Data Source=norby11\\SQLEXPRESS;Integrated Security=SSPI;Connect Timeout=30;User Instance=True;Initial Catalog=databasename;");
You can manage SQL Express with Management studio express, still CTP and it works well for me.
shoagMSFT
I'll take any help anybody is willing to give.
Toby
Taniabr
SqlConnection conn = new SqlConnection("Data Source=norby11\\SQLEXPRESS;Integrated Security=SSPI;Connect Timeout=30;User Instance=True");
string ndeText=numberNode.Text;
string insertString = @"INSERT INTO table3(nodenames2) VALUES(ndeText)";
SqlCommand cmd = new SqlCommand(insertString,conn);
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch
{
conn.Close();
conn.Dispose();
cmd.Dispose();
}
finally
{
if (conn != null)
{
conn.Close();
conn.Dispose();
cmd.Dispose();
}
}
}
The line
cmd.ExecuteNonQuery();
is where the error occurs
Aleborg
Witi
Hi,
FYI: Is your problem solved If yes then can you click on "Mark as Answer" so that we will know your post is being answered.
Thank you,
Bhanu.
LMcFarlin
bear007
// string insertString = @"INSERT INTO table3(nodenames2) VALUES(ndeText)";
Try
string insertString = @"INSERT INTO table3(nodenames2) VALUES('" + ndeText +"')";
Two errors - not putting the string in quotes, and putting a variable name within quotes :-)
It's possible that the bad SQL was causing the error, try that and see.
invalid display name
So, I still haven't figured out why I can't process my insert query. Is there any way to adjust permissions in SQLExpress It's kinda acting like this is the problem. I think I encountered it in VS2003. Any help
thanks
toby
Amit Paka
What connection string are you using What's the database name
Hannodb
connString is:
SqlConnection conn = new SqlConnection("Data Source=norby11\\SQLEXPRESS;Integrated Security=SSPI;Connect Timeout=30;User Instance=True;Initial Catalog=nodes10;");
and
string insertString = @"INSERT INTO table3(nodenames) VALUES(whatever_nothing_works_anyway)";
SqlCommand cmd = new SqlCommand(insertString,conn);