473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Cant connect to db......

Hello

I made a .udl file and tested its connectionstring and it worked, when i put
the connectionstring in the code it says that it is invalid? what have i
done wrong?

<%@ Page Language="vb" debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
BindData()
End Sub

Sub BindData()
Dim conn as new
SqlConnection(ConfigurationSettings.AppSettings("P rovider=SQLOLEDB.1;Persist
Security Info=False;User ID=myuser;Password=mypass;Initial Catalog=lab;Data
Source=192.168.8.5"))
const strsql as String = "myTestProc"

Dim mycomm as New SqlCommand(strsql,conn)
conn.open()

test.Datasource =
mycomm.ExecuteReader(CommandBehavior.CloseConnecti on)
test.Databind()

End Sub

</script>
<html>
<head>
</head>
<body>
<asp:datagrid id="test" runat="server"></asp:datagrid>
</body>
</html>
Nov 18 '05 #1
7 1295
The ConfigurationSettings.AppSettings() call is to retrieve a value set in
the Web.Config file, like this. If this is what you are trying to do, try
this (in your Web.config file)
<configuration>

<appSettings>

<add key="ConnectionString" value="Provider=SQLOLEDB.1;Persist Security
Info=False;UserID=myuser;Password=mypass;Initial Catalog=lab;Data
Source=192.168.8.5" />

</appSettings>

....

</configuration>

Then in your code, just change it to this.

Dim conn as new
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))

This should work,
--Michael

"Lasse Edsvik" <la***@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hello

I made a .udl file and tested its connectionstring and it worked, when i put the connectionstring in the code it says that it is invalid? what have i
done wrong?

<%@ Page Language="vb" debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
BindData()
End Sub

Sub BindData()
Dim conn as new
SqlConnection(ConfigurationSettings.AppSettings("P rovider=SQLOLEDB.1;Persist Security Info=False;User ID=myuser;Password=mypass;Initial Catalog=lab;Data Source=192.168.8.5"))
const strsql as String = "myTestProc"

Dim mycomm as New SqlCommand(strsql,conn)
conn.open()

test.Datasource =
mycomm.ExecuteReader(CommandBehavior.CloseConnecti on)
test.Databind()

End Sub

</script>
<html>
<head>
</head>
<body>
<asp:datagrid id="test" runat="server"></asp:datagrid>
</body>
</html>

Nov 18 '05 #2
hmm, some progress but still error :)

Keyword not supported: 'provider'

i tried to remove Provider= but it whined about next one :)

/Lasse

"Michael" <raterus@localhost> wrote in message news:uk*************@TK2MSFTNGP12.phx.gbl...
The ConfigurationSettings.AppSettings() call is to retrieve a value set in
the Web.Config file, like this. If this is what you are trying to do, try
this (in your Web.config file)
<configuration>

<appSettings>

<add key="ConnectionString" value="Provider=SQLOLEDB.1;Persist Security
Info=False;UserID=myuser;Password=mypass;Initial Catalog=lab;Data
Source=192.168.8.5" />

</appSettings>

...

</configuration>

Then in your code, just change it to this.

Dim conn as new
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))

This should work,
--Michael

"Lasse Edsvik" <la***@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hello

I made a .udl file and tested its connectionstring and it worked, when i

put
the connectionstring in the code it says that it is invalid? what have i
done wrong?

<%@ Page Language="vb" debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
BindData()
End Sub

Sub BindData()
Dim conn as new

SqlConnection(ConfigurationSettings.AppSettings("P rovider=SQLOLEDB.1;Persist
Security Info=False;User ID=myuser;Password=mypass;Initial

Catalog=lab;Data
Source=192.168.8.5"))
const strsql as String = "myTestProc"

Dim mycomm as New SqlCommand(strsql,conn)
conn.open()

test.Datasource =
mycomm.ExecuteReader(CommandBehavior.CloseConnecti on)
test.Databind()

End Sub

</script>
<html>
<head>
</head>
<body>
<asp:datagrid id="test" runat="server"></asp:datagrid>
</body>
</html>


Nov 18 '05 #3
http://www.able-consulting.com/dotne..._Providers.htm

This should help you construct a valid connection string.

"Lasse Edsvik" <la***@nospam.com> wrote in message
news:OX*************@tk2msftngp13.phx.gbl...
hmm, some progress but still error :)

Keyword not supported: 'provider'

i tried to remove Provider= but it whined about next one :)

/Lasse

"Michael" <raterus@localhost> wrote in message
news:uk*************@TK2MSFTNGP12.phx.gbl...
The ConfigurationSettings.AppSettings() call is to retrieve a value set in
the Web.Config file, like this. If this is what you are trying to do, try
this (in your Web.config file)
<configuration>

<appSettings>

<add key="ConnectionString" value="Provider=SQLOLEDB.1;Persist Security
Info=False;UserID=myuser;Password=mypass;Initial Catalog=lab;Data
Source=192.168.8.5" />

</appSettings>

...

</configuration>

Then in your code, just change it to this.

Dim conn as new
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))

This should work,
--Michael

"Lasse Edsvik" <la***@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hello

I made a .udl file and tested its connectionstring and it worked, when i

put
the connectionstring in the code it says that it is invalid? what have i
done wrong?

<%@ Page Language="vb" debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
BindData()
End Sub

Sub BindData()
Dim conn as new

SqlConnection(ConfigurationSettings.AppSettings("P rovider=SQLOLEDB.1;Persist
Security Info=False;User ID=myuser;Password=mypass;Initial

Catalog=lab;Data
Source=192.168.8.5"))
const strsql as String = "myTestProc"

Dim mycomm as New SqlCommand(strsql,conn)
conn.open()

test.Datasource =
mycomm.ExecuteReader(CommandBehavior.CloseConnecti on)
test.Databind()

End Sub

</script>
<html>
<head>
</head>
<body>
<asp:datagrid id="test" runat="server"></asp:datagrid>
</body>
</html>


Nov 18 '05 #4
You are using an OLEDB connection string with the SQL Server native .NET provider. Either use the OLEDB provider (the OleDbConnection class and the OleDb related classes) or use a string compatible with the SQL Server provider. You can look up the proper parameters for each provider. In particular, you will have to remove the provider and persist security info parameters.

Eran
"Lasse Edsvik" <la***@nospam.com> wrote in message news:OX*************@tk2msftngp13.phx.gbl...
hmm, some progress but still error :)

Keyword not supported: 'provider'

i tried to remove Provider= but it whined about next one :)

/Lasse

"Michael" <raterus@localhost> wrote in message news:uk*************@TK2MSFTNGP12.phx.gbl...
The ConfigurationSettings.AppSettings() call is to retrieve a value set in
the Web.Config file, like this. If this is what you are trying to do, try
this (in your Web.config file)
<configuration>

<appSettings>

<add key="ConnectionString" value="Provider=SQLOLEDB.1;Persist Security
Info=False;UserID=myuser;Password=mypass;Initial Catalog=lab;Data
Source=192.168.8.5" />

</appSettings>

...

</configuration>

Then in your code, just change it to this.

Dim conn as new
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))

This should work,
--Michael

"Lasse Edsvik" <la***@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hello

I made a .udl file and tested its connectionstring and it worked, when i

put
the connectionstring in the code it says that it is invalid? what have i
done wrong?

<%@ Page Language="vb" debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
BindData()
End Sub

Sub BindData()
Dim conn as new

SqlConnection(ConfigurationSettings.AppSettings("P rovider=SQLOLEDB.1;Persist
Security Info=False;User ID=myuser;Password=mypass;Initial

Catalog=lab;Data
Source=192.168.8.5"))
const strsql as String = "myTestProc"

Dim mycomm as New SqlCommand(strsql,conn)
conn.open()

test.Datasource =
mycomm.ExecuteReader(CommandBehavior.CloseConnecti on)
test.Databind()

End Sub

</script>
<html>
<head>
</head>
<body>
<asp:datagrid id="test" runat="server"></asp:datagrid>
</body>
</html>


Nov 18 '05 #5
Lasse,

Connection String that should work for you:

User ID=myuser;Password=mypassword;Initial Catalog=MyCat;Data
Source=Myserver
Dan

"Eran Amitai" <er********@hotmail.com> wrote in message
news:#$**************@tk2msftngp13.phx.gbl...
You are using an OLEDB connection string with the SQL Server native .NET
provider. Either use the OLEDB provider (the OleDbConnection class and the
OleDb related classes) or use a string compatible with the SQL Server
provider. You can look up the proper parameters for each provider. In
particular, you will have to remove the provider and persist security info
parameters.

Eran
"Lasse Edsvik" <la***@nospam.com> wrote in message
news:OX*************@tk2msftngp13.phx.gbl...
hmm, some progress but still error :)

Keyword not supported: 'provider'

i tried to remove Provider= but it whined about next one :)

/Lasse

"Michael" <raterus@localhost> wrote in message
news:uk*************@TK2MSFTNGP12.phx.gbl...
The ConfigurationSettings.AppSettings() call is to retrieve a value set in the Web.Config file, like this. If this is what you are trying to do, try this (in your Web.config file)
<configuration>

<appSettings>

<add key="ConnectionString" value="Provider=SQLOLEDB.1;Persist Security
Info=False;UserID=myuser;Password=mypass;Initial Catalog=lab;Data
Source=192.168.8.5" />

</appSettings>

...

</configuration>

Then in your code, just change it to this.

Dim conn as new
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))

This should work,
--Michael

"Lasse Edsvik" <la***@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hello

I made a .udl file and tested its connectionstring and it worked, when i
put
the connectionstring in the code it says that it is invalid? what have

i done wrong?

<%@ Page Language="vb" debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
BindData()
End Sub

Sub BindData()
Dim conn as new

SqlConnection(ConfigurationSettings.AppSettings("P rovider=SQLOLEDB.1;Persist
Security Info=False;User ID=myuser;Password=mypass;Initial

Catalog=lab;Data
Source=192.168.8.5"))
const strsql as String = "myTestProc"

Dim mycomm as New SqlCommand(strsql,conn)
conn.open()

test.Datasource =
mycomm.ExecuteReader(CommandBehavior.CloseConnecti on)
test.Databind()

End Sub

</script>
<html>
<head>
</head>
<body>
<asp:datagrid id="test" runat="server"></asp:datagrid>
</body>
</html>


Nov 18 '05 #6
Yes, I Agree with Eran and Lasse,

Lucky_Hemya :arrow:

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 18 '05 #7
Hello,
I'm having the same problem as Lasse, and I've tried to the suggestions from Michael with no luck. When I put the

<appSettings>
<Add key="connString" Value="Server=servername;initial catalog=databasename;Uid=user;Pwd=password" /></appSettings>

right underneath the <configuration> section in web.config file I get this error message:
Parser Error Message: Unrecognized configuration section 'appSettings'

If I put the <appSetting> section in the <system.web> section of the web.config file my call
Dim cn As New SqlConnection(ConfigurationSettings.AppSettings("c onnString"))
returns nothing from AppSettings.

The machine.config has the appSetting section defined in the <system.web> section so that is where I thought the web.config file should have it also. At this point, I'm out of ideas, it seems like it should just work but it's not.
Jamie
Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: tony010409020622 | last post by:
My WebForm1.aspx works fine when I connect via localhost, AND when I connect using the IP address. HOWEVER, NO ONE ELSE can connect using my IP address. Capitalization is correct, Firewall is off,...
2
by: yodboy | last post by:
hi there Im going nuts - any help appreciated trying to connect to access db over a network so far - I can connect to the db using the same odbc with excel I can connect to a copy of the...
0
by: =?Utf-8?B?Q2hpV2hpdGVTb3g=?= | last post by:
Hi, i got machine A that has sql2005, vs2005 project. project runs okay there. But when i copied that whole project folder to machine B, running sql2005, VS2005, edited the web.config file to...
3
by: =?Utf-8?B?Y29yeQ==?= | last post by:
i cant get the playstation 3 to connect to call of duty 4 online through the router but i am able to connect to the game online through the modem. I am able to still get on the internet through the...
6
flexsingh
by: flexsingh | last post by:
Hello there, I have constructed a option of choosing a court only available when member no = "0". This works fine and is in the first code: - <html> <head> </head> <body background="main...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.