c# - Problem with Basic SQL Stuff -
I'm the first in SQL I have this problem. Firstly I shd I know that I have installed SQL 2005 server then a ConsoleApp is created and the rest of the code is as follows:
using the system; Using System.Collections.Generic; Using System.Text; Using System.Data.SqlClient; Namespace Console Application 1 {class} {Static Wide Men (String [] AGRs) {SqlConnection myConnection = New SqlConnection ("User ID = UserID;" + "Password = Valid Passwords;" + "TrustedConnect = Yes;" + "Data Source = Localhost; "+" Connection Timeout = 300 "); Try {myConnection.Open (); } Hold (exception e) {Console.WriteLine (e.ToString ()); } SqlCommand myCommand = new SqlCommand ("Insert in table (column1, column2)" + "value ('string', 1)", my connection); MyCommand.ExecuteNonQuery (); }}} When I run it ... I found an unrestricted exception of the type of System.Data.SqlClient.SqlException System.Data.dll MyCommand.ExecuteNonQuery ();
I find out where I'm going wrongly guide. I just want to do simple things. Write it and read it. But I get an error even when I put it.
You are not using the database set the initial catalog query to that database in your connection string Do the table is "table". Or, include the dbName..table values ...
In addition, check out. Know it, use it, like it.
Comments
Post a Comment