c# - Invalid Object Name in ExecuteNonQuery -


i'm trying develop application allows track spending part of class. run error "invalid object name 'dbo.acctransactions"

my windows form code:

    string command = "insert dbo.acctransactions (id, transact_id, payee, dateof, amount, category)"                             + "values (@id, @transact_id, @payee, @dateof, @amount, @category)";         sqlcommand cmd = new sqlcommand(command, con);         cmd.parameters.addwithvalue("@id", 1);         cmd.parameters.addwithvalue("@transact_id", 2);         cmd.parameters.addwithvalue("@payee", payeetextbox.text);         cmd.parameters.addwithvalue("@dateof", datetime.today);         cmd.parameters.addwithvalue("@amount", convert.todecimal(amounttextbox.text));         cmd.parameters.addwithvalue("@category", categorytextbox.text);          con.open();         cmd.executenonquery();         con.close(); 

my connection string:

     sqlconnection con = new sqlconnection(@"data source=ivy\sqlexpress;initial catalog=budgettracker;integrated security=sspi;connect timeout=15;encrypt=false;trustservercertificate=false"); 

my database has table "dbo.acctransactions" , performs in ssms.

any assistance great!

i guess missing database name in connection string.

sqlconnection con = new sqlconnection(@"data source=ivy\sqlexpress;integrated security=true;connect timeout=15;encrypt=false;trustservercertificate=false"); 

try putting name of database in following string.

 sqlconnection con = new sqlconnection(@"data source=ivy\sqlexpress; initial catalog=your_database_name;integrated security=true;connect timeout=15;encrypt=false;trustservercertificate=false"); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -