Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Web config code as follows

HTML
<connectionstrings>

<add name="dbconnection" connectionstring="Mymachine\SQLSERVER2012; Integrated Security=true; Initial Catalog=Testing" providername="System.Data.SqlClient" />

</connectionstrings>




in .aspx code as follows

HTML
 protected void Page_Load(object sender, EventArgs e)
          {
            if (!IsPostBack)
            {

                this.BindGrid();
            }
        }



    private void BindGrid()
        {
string strConnString = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
            using (SqlConnection con = new SqlConnection(strConnString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText ="select Tb_Employee";
                    cmd.Connection = con;
                    con.Open();
                    gvEmpdetails.DataSource = cmd.ExecuteReader();
                    gvEmpdetails.DataBind();
                    con.Close();
                }
            }
      }





When i run the application shows error as follows

>Keyword not supported: 'Mymachine\sqlserver2012; integrated security'

please what is the mistake in my above code

What I have tried:

Web config code as follows


HTML
<connectionstrings>

<add name="dbconnection" connectionstring="Mymachine\SQLSERVER2012; Integrated Security=true; Initial Catalog=Testing" providername="System.Data.SqlClient" />

</connectionstrings>


protected void Page_Load(object sender, EventArgs e)
          {
            if (!IsPostBack)
            {

                this.BindGrid();
            }
        }



    private void BindGrid()
        {
string strConnString = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
            using (SqlConnection con = new SqlConnection(strConnString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText ="select Tb_Employee";
                    cmd.Connection = con;
                    con.Open();
                    gvEmpdetails.DataSource = cmd.ExecuteReader();
                    gvEmpdetails.DataBind();
                    con.Close();
                }
            }
      }


in .aspx code as follows

<pre lang="HTML">




When i run the application shows error as follows

>Keyword not supported: 'Mymachine\sqlserver2012; integrated security'

please what is the mistake in my above code
Posted
Updated 2-May-16 0:00am
v2
Comments
madhav_jain 2-May-16 3:24am    
check your connection string in Web.config file it should be in below format

<add name="ConnectionStringName" providername="System.Data.SqlClient" connectionstring="Data Source=ServerName;Initial Catalog=DatabaseName;Integrated Security=False;User Id=userid;Password=password; ></add></div> <div id=" editdialogplaceholder"="">
Karthik_Mahalingam 5-May-16 7:09am    
You never used to close any of the answers to your question..
Please then and there close the posts by marking it as answer or post your own answer which worked for you..
dont leave the questions as such. Its not good. being you are an active user you shouldnt do like this.

Try following-
XML
<connectionstrings>
<add name="dbconnection" connectionstring="server=Mymachine\SQLSERVER2012; Integrated Security=true; Initial Catalog=Testing" providername="System.Data.SqlClient" />
</connectionstrings>

or,
XML
<connectionstrings>
<add name="dbconnection" connectionstring="Data Source=Mymachine\SQLSERVER2012; Integrated Security=true; Initial Catalog=Testing" providername="System.Data.SqlClient" />
</connectionstrings>


You are missing "server=" or "Data Source=" in your connection string while providing the server name.

Hope, it helps :)
 
Share this answer
 
v3
C#
check your connection string in Web.config file it should be in below format



<add name="ConnectionStringName">
providerName="System.Data.SqlClient"
connectionString="Data Source=ServerName;Initial Catalog=DatabaseName;Integrated Security=False;User Id=userid;Password=password;>
 
Share this answer
 
v2
Its connection string error
use below syntax
C#
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;
Password=myPassword;

and from your code it looks you have missed 'Server' and 'Database' keyword.
correct them. it will resolve your issue
 
Share this answer
 
Just do like this...

If you don't want to give your machine name, just after the Data Source = .\SQLEXPRESS; add DOT behind slash! it will works fine...




HTML
<connectionstrings>>
    <add name="SAIConn" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Recuitment.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900