TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
narasiman rao
NA
519
768.5k
user is not associated with a trusted sqlserver connection.
Oct 20 2013 10:29 AM
Code as follows
Global Function code as follows
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public class GlobalFunction
{
public SqlConnection con = null;
private string connectionstring = "Data Source=god;connect timeout = 120; Initial Catalog=CRMS Trusted_Connection=True";
private SqlCommand cmd;
private SqlDataReader dr;
public string Error;
public GlobalFunction()
{
}
public void BindConn()
{
con = new SqlConnection();
con.ConnectionString = connectionstring;
con.Open();
}
public void InsertData(string SQL)
{
try
{
BindConn();
cmd = new SqlCommand(SQL, con);
cmd.ExecuteReader();
}
catch (Exception e1)
{
Error = e1.Message.ToString();
}
}
public SqlDataReader ReadSql(string SQL)
{
con = new SqlConnection(connectionstring);
con.Open();
cmd = new SqlCommand(SQL, con);
dr = cmd.ExecuteReader();
return (dr);
}
public string CntString()
{
return connectionstring;
}
}
Loginpage code as follows;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class LOGIN : System.Web.UI.Page
{
private GlobalFunction GFun = new GlobalFunction();
private SqlDataReader Dr;
private string Sql;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
Sql = "select * from Tb_Login";
Dr = GFun.ReadSql(Sql);
while (Dr.Read())
{
if (txtUsername.Text.Equals(Dr[0].ToString().Trim()) && (txtPassword.Text.Equals(Dr[1].ToString().Trim())))
{
//Response.Redirect("CUSTOMER REGISTRATION.aspx");
lblmessage.Text = "User name and password match";
}
else
{
lblmessage.Text = "User name and password does not match";
}
}
}
catch (Exception ex)
{
lblmessage.Text = ex.ToString();
return;
}
}
}
Error as follows
Login failed for user
the user is not associated with a trusted sql server connection.
please help me what is the problem in my code.
regards,
Rao.
Thanks.
Reply
Answers (
1
)
SQL Query to pass a value concerned with primary key
Simple queries ?