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
Deekshaa Singh Chauhan
NA
178
33k
how to connect database file in my asp.net project
Apr 4 2018 5:12 AM
I have restored database when i connect sql it shows server name blank i entered [.] dot it connect.
when i run my asp.net web application its show instance error.
my connection string is:
<
add
name
=
"WarehouseWebsiteString"
connectionString
="Data Source=hostingmssql10;Network Library=dbmssocn;Connection Timeout=15;Packet Size=4096;Integrated Security=no;User ID=bea3de-warehousebissdscom; Encrypt=no;Initial Catalog=bea3de-warehousebissdscom; Password=1234;"
providerName
="System.Data.SqlClient"
/>
i have create login page using database but it not login give error in web.config file:
<?
xml
version
=
"1.0"
?>
<
configuration
>
<
appSettings
>
<
add
key
=
"warehouse_DataAccessLayerType"
value
=
"warehouse.DataAccessLayer.SQLDataAccess"
/>
</
appSettings
>
<
connectionStrings
>
<!--<add name="WarehouseWebsiteString" connectionString="Data Source=BISWEBSERVER\SQLSERVER2005; DataBase=Warehouse; User Id=sa; Password=xfiles_76;"/>-->
<
add
name
=
"WarehouseWebsiteString"
connectionString
=
"Data Source=hostingmssql06;Network Library=dbmssocn;Connection Timeout=15;Packet Size=4096;Integrated Security=no;User ID=bea3de-warehousebissdscom; Encrypt=no;Initial Catalog=bea3de-warehousebissdscom; Password=1234;"
providerName
=
"System.Data.SqlClient"
/>
</
connectionStrings
>
<
system.web
>
<
globalization
culture
=
"en-US"
/>
<
compilation
debug
=
"true"
targetFramework
=
"4.5"
/>
<
authentication
mode
=
"Windows"
/>
<
customErrors
mode
=
"Off"
/>
<
pages
theme
=
"Theme1"
maintainScrollPositionOnPostBack
=
"true"
controlRenderingCompatibilityVersion
=
"3.5"
clientIDMode
=
"AutoID"
/>
</
system.web
>
<
system.webServer
>
<
directoryBrowse
enabled
=
"true"
/>
</
system.webServer
>
</
configuration
>
i'm doing this in login.aspcx.cs:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.Security;
using
System.Data.SqlClient;
using
System.Web.Configuration;
public
partial
class
AdminLogin : System.Web.UI.Page
{
SqlConnection con =
new
SqlConnection(WebConfigurationManager.ConnectionStrings[
"WarehouseWebsiteString"
].ToString());
protected
void
Page_Load(
object
sender, EventArgs e)
{
error.Visible =
false
;
}
protected
void
imgBtnLogin_Click(
object
sender, ImageClickEventArgs e)
{
try
{
using
(con =
new
SqlConnection(WebConfigurationManager.ConnectionStrings[
"WarehouseWebsiteString"
].ToString()))
{
con.Open();
string
qry =
"select * from tblLoginDetails where UserName='"
+ txtUserName.Text +
"' and Password='"
+ txtPassword.Text +
"'"
;
SqlCommand cmd =
new
SqlCommand(qry, con);
int
count = Convert.ToInt32(cmd.ExecuteScalar());
if
(count == 1)
{
Session[
"UserName"
] = txtUserName.Text.Trim();
Response.Redirect(
"~/Admin/Default.aspx"
);
error.Visible =
false
;
}
else
{
error.Visible =
true
;
}
}
con.Close();
}
catch
(Exception ex)
{
Response.Write(ex.Message);
}
}
}
what can i do i dont understand where mistak how to sove this
Reply
Answers (
4
)
Export All Data (Paging in a Gridview ) To Excel sheet
Issue in Wpf Inverted DataGrid Row, Column Resize