I Want To Insert Data Into A Sql Server Databse Using C#
I want to insert data into a SQL Server database using C#. There is no error in my code. But after entering the data I traverse. It shows me the data. But when I open the database
Solution 1:
try to put your connection string in a app.config file and then retrieve it or you can hard code it in your insert.cs file. I have checked it using app.config file and it was working. Here what I did.
app.config file
<?xml version="1.0" encoding="utf-8" ?><configuration><connectionStrings><addname="connectionString"connectionString="Server=192.168.8.295;Database=TestDB;
uid=Tapan;pwd=kumar;"/></connectionStrings></configuration>
Then just replace the thing you are retriving from settings in your insert.cs page
conString = ConfigurationManager.ConnectionStrings["connectionString"].ToString();
And remove this thing
objConnect.Sql = Properties.Settings.Default.SQL;
And check once if it is working or not. For me it was working.
Still if you have problem then first put try catch in your code and debug thoroughly first and see where your code is dying..
Post a Comment for "I Want To Insert Data Into A Sql Server Databse Using C#"