Advertisement

04.04.2008 at 02:04AM PDT, ID: 23295367
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

ASP.NET(vb) COnnect to Datasource Specified in Code Behind

Asked by edjones1 in Visual Studio, Programming for ASP.NET

Tags:

Hi All

Please help!

I've got a SQL datasource on one of my .aspx pages

eg

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:WebDataConnectionString %>"


This all works fine but when I go to upload it onto my ISP's webserver it does not work as I get the ' SQL Server Doea Not Allow Remore COnnections' error message.


My ISP now tells me that I can't connect to the SQL Db via the web.config file and I have to do it in the code behind.  Below is an example that they've sent me.
What I don't understand is how to call this datasource in the code behind from my formviews or datagrids etc....

Also what about my update and delete statements on my .aspx pages? (DeleteCommand="DELETE FROM [Bookings] WHERE [ID] = ?" InsertCommand="INSERT INTO [Bookings] ([CalendarDate], [Booked], [BookingID]) VALUES (?, 'No', ?)")


How would I do all that below and call them as delete or insert statements?

-----------------------------------------------------------------------------------------------
My isp connection code example


Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
<%@ Page Language="VB" %>
<script runat="server">
    
    Sub Page_Data
    	Dim oDR as System.Data.SQLClient.SQLDataReader
        Dim oCom As System.Data.SQLClient.SqlCommand
        Dim oConn as System.Data.SQLClient.SQLConnection
        try
            oConn = New System.Data.SQLClient.SQLConnection ("server=mssqlxxx.1and1.com; initial catalog=dbxxxxxxxxx;uid=dboxxxxxxxxx;pwd=xxxxxxxx")
			oConn.Open()
			oCom = New System.Data.SQLClient.SqlCommand()
			oCom.Connection = oConn
			oCom.CommandText = "SELECT * FROM products"
			oDR = oCom.ExecuteReader()
			While oDR.Read
	    		Response.Write(oDR.Item("id") & ", " & oDR.Item("price"))
	    		Response.Write("<BR/>")
    		End While
        catch
            Response.Write("Error:" & err.Description)
        Finally
        	oDR = Nothing
        	oCom = Nothing
        	oConn.Close()
        	oConn = Nothing
        end try
    End Sub
</script>
<html>
<title>Queries from the MS-SQL database with ASP.NET</title>
<body bgcolor="FFFFFF">
<h2>Query from table <b>products</b> with ASP.NET</h2>
<%Page_Data()%>
</body>
</html>
[+][-]04.04.2008 at 02:15AM PDT, ID: 21279930

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Studio, Programming for ASP.NET
Tags: Asp.net VB
Sign Up Now!
Solution Provided By: Velio
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.08.2008 at 03:59PM PDT, ID: 21959150

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.13.2008 at 06:49AM PDT, ID: 21992525

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628