Well. Yeah "s" was the problem and Int ->Int32. Now i want to know how to bind Button1 with SqlDataSource. When i click the button to open the GridView(and before that to be hidden of course) and to execute my written query?
An attempt to attach an auto-named database for file D:\WebSites\PhoneDirectory\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Here i want to say that my database is not in the same directory as the web site:
The ASPNETDB.MDF is the default database for using the ASP.NET Application Services, which includes profiles, roles, membership and more. It gets automatically generated whenever you use one of the above services. I believe you want to use a database which
is already exist somewhere on the server. In this case your connection string which you set for the SqlDataSource control must include server name, login and password, like
smirnov
All-Star
23670 Points
4051 Posts
Re: Unable to make connection to database?
Aug 17, 2010 10:06 PM|LINK
Great, at least one problem less.
I guess it's a typo, the property must be named as ConnectionString (no -s at the end).
Veschich
Member
29 Points
279 Posts
Re: Unable to make connection to database?
Aug 18, 2010 05:58 AM|LINK
Well. Yeah "s" was the problem and Int ->Int32. Now i want to know how to bind Button1 with SqlDataSource. When i click the button to open the GridView(and before that to be hidden of course) and to execute my written query?
smirnov
All-Star
23670 Points
4051 Posts
Re: Unable to make connection to database?
Aug 18, 2010 07:19 AM|LINK
<asp:Button OnClick="Button_Click" ...
then put at the top of the page
<%@ Page Language="vb" %>
...
<script language="VB" runat="server">
Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
GridViewID_HERE.Visible = True
End Sub
</script>
Veschich
Member
29 Points
279 Posts
Re: Unable to make connection to database?
Aug 18, 2010 07:43 AM|LINK
I'm writing in C#?
Is this code going to work?
smirnov
All-Star
23670 Points
4051 Posts
Re: Unable to make connection to database?
Aug 18, 2010 07:54 AM|LINK
<script runat="server"> protected void Button_Click(object sender, EventArgs e) { GridViewID_HERE.Visible = true; } </script>Veschich
Member
29 Points
279 Posts
Re: Unable to make connection to database?
Aug 18, 2010 08:47 AM|LINK
Another problem come up:
An attempt to attach an auto-named database for file D:\WebSites\PhoneDirectory\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Here i want to say that my database is not in the same directory as the web site:
1. Is it have to be?
2. Why try to open aspnetdb.mdf ?
smirnov
All-Star
23670 Points
4051 Posts
Re: Unable to make connection to database?
Aug 18, 2010 09:04 AM|LINK
The ASPNETDB.MDF is the default database for using the ASP.NET Application Services, which includes profiles, roles, membership and more. It gets automatically generated whenever you use one of the above services. I believe you want to use a database which is already exist somewhere on the server. In this case your connection string which you set for the SqlDataSource control must include server name, login and password, like
"Data Source=SERVER;Persist Security Info=True;User ID=myId;Password=myPW"
Veschich
Member
29 Points
279 Posts
Re: Unable to make connection to database?
Aug 18, 2010 09:19 AM|LINK
Where to add it:
here ->
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <connectionStrings></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <add name="ThisIsMyConnection"</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> providerName="System.Data.SqlClient" /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </connectionStrings></div> <div></div><connectionStrings>
<add name="ThisIsMyConnection"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
<div>or -> in SqlData Control</div>smirnov
All-Star
23670 Points
4051 Posts
Re: Unable to make connection to database?
Aug 18, 2010 09:21 AM|LINK
It must be in the web.config file.
Veschich
Member
29 Points
279 Posts
Re: Unable to make connection to database?
Aug 18, 2010 09:32 AM|LINK
here's what in my webconfig file:
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI; Persist Security Info=True;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true; User ID=___\veschich;"
but i'm not sure about some stuff.
My server name = "____\VESOMANIA"
My user name = "____\veschich"
i don't have a password.
Is this the way webconfig has to be?