Hello there,

I am in need of major help. I am trying to convert my ASP classic website to ASP.net. Now my problem is with reading and controlling of the data found in my SQL Server DB. I have managed to connecting to the database and read the records there and display them in a grid but I dont want that. Because of the design, my website requires me to place every field in its position and also use the Id of the record as a link to display more information of that record. In other words, I need to control each field of each record freely and place them at a position inside my default.aspx page as I please (meaning not by on Page Load or on click). I used to do this in classic ASP via recordset and Loop and then use it whereever I want and while calling on each field via the recordset. How can I do this in ASP.NET. For example convert the below code exactly as it is to ASP.net so that I can use freely. I have found many solution none of which works for me (gridview, dataadapter, etc.). The code is:

Function SetLanguage() 

Dim Sql,rs,langStr,lId,lLanguage,RqstSession 

RqstSession = Session("lngID")  'THIS COULD BE A VARIABLE SET AS FIXED OR PASSED ON TO THE SUB



langStr = "<select name="lang">"

set rs=Server.CreateObject("ADODB.recordset") 

Sql="SELECT * FROM tblSystemLang WHERE lVisible = 1 AND lLimitations NOT LIKE '%<" & DeCrypt(Session("ClientId")) & ">%' ORDER BY lId ASC" 

rs.Open Sql,Connection_Variable,3,1 

while not rs.eof 

lId =rs("lId") 

lLanguage =rs("lLanguage") 

if Cint(RqstSession) = Cint(lId) then 

          langStr = langStr & "<option value=""" & lId & """ SELECTED>" & lLanguage & "</option>" & VbCrlf 

else 

          langStr = langStr & "<option value=""" & lId & """>" & lLanguage & "</option>" & VbCrlf 

end if 

rs.movenext 

wend 

 

rs.Close 

set rs=nothing 

set Sql=nothing 



langStr = langStr & "</select>"

SetLanguage = langStr 

 

End Function

Thanks
Awny

Hello there,

I am in need of major help. I am trying to convert my ASP classic website to ASP.net. Now my problem is with reading and controlling of the data found in my SQL Server DB. I have managed to connecting to the database and read the records there and display them in a grid but I dont want that. Because of the design, my website requires me to place every field in its position and also use the Id of the record as a link to display more information of that record. In other words, I need to control each field of each record freely and place them at a position inside my default.aspx page as I please (meaning not by on Page Load or on click). I used to do this in classic ASP via recordset and Loop and then use it whereever I want and while calling on each field via the recordset. How can I do this in ASP.NET. For example convert the below code exactly as it is to ASP.net so that I can use freely. I have found many solution none of which works for me (gridview, dataadapter, etc.). The code is:

Function SetLanguage() 

Dim Sql,rs,langStr,lId,lLanguage,RqstSession 

RqstSession = Session("lngID")  'THIS COULD BE A VARIABLE SET AS FIXED OR PASSED ON TO THE SUB



langStr = "<select name="lang">"

set rs=Server.CreateObject("ADODB.recordset") 

Sql="SELECT * FROM tblSystemLang WHERE lVisible = 1 AND lLimitations NOT LIKE '%<" & DeCrypt(Session("ClientId")) & ">%' ORDER BY lId ASC" 

rs.Open Sql,Connection_Variable,3,1 

while not rs.eof 

lId =rs("lId") 

lLanguage =rs("lLanguage") 

if Cint(RqstSession) = Cint(lId) then 

          langStr = langStr & "<option value=""" & lId & """ SELECTED>" & lLanguage & "</option>" & VbCrlf 

else 

          langStr = langStr & "<option value=""" & lId & """>" & lLanguage & "</option>" & VbCrlf 

end if 

rs.movenext 

wend 

 

rs.Close 

set rs=nothing 

set Sql=nothing 



langStr = langStr & "</select>"

SetLanguage = langStr 

 

End Function

Thanks
Awny

public string SetLanguage()
    {
        string RqstSession, langStr,lId,lLanguage;
        SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["UR COnnection String"].ToString());
        SqlDataReader reader = null;
        RqstSession = Session["lngID"].ToString();
        langStr = "<select name='lang'>";
        SqlCommand cmd = new SqlCommand("SELECT * FROM tblSystemLang WHERE lVisible = 1 AND lLimitations NOT LIKE '"+Session["ClientId"]+"' ORDER BY lId ASC", Conn);
        try
        {
            Conn.Open();
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                lId = reader["lId"].ToString();
                lLanguage = reader["lLanguage"].ToString();
                if (int.Parse(RqstSession) == int.Parse(lId))
                    langStr += "<option value='" + lId + "' SELECTED>" + lLanguage + "</option>";
                else
                    langStr += "<option value='" + lId + "'>" + lLanguage + "</option>";
            }
        }
        catch
        {
        }
        finally
        {
            reader.Close();
            Conn.Close();
        }
        return langStr;
    }

Hi the above is the function u required. Reply me if u r required more.

but u can use Dropdownlist instead of creating HTML dropdown in serverside.

Thank you so much for responding back. After using your code and since I am using VB in my ASP.NET project, I get all errors from { to string to everything. I am deep need of this. I will sum up what I need. A small function that loop through an SQL statment and from there I can control any field in the table of the database so I can place it (position and design) as I please inside my ASP.NET page. Thanks Awny

You are right I can use the dropdownlist but then I cannot control which option is chosen as it all depends on the request.querystring() from previous pages. In ASP classic it was very to control anything from database to request.querystring in ASP.net I am having a hard time.

You are right I can use the dropdownlist but then I cannot control which option is chosen as it all depends on the request.querystring() from previous pages. In ASP classic it was very to control anything from database to request.querystring in ASP.net I am having a hard time.

Hi this is the vb form of code

Public Function SetLanguage() As String
        Dim RqstSession As String, langStr As String, lId As String, lLanguage As String
        Dim Conn As New SqlConnection(ConfigurationManager.ConnectionStrings("UR COnnection String").ToString())
        Dim reader As SqlDataReader = Nothing
        RqstSession = Session("lngID").ToString()
        langStr = "<select name='lang'>"
        Dim cmd As New SqlCommand("SELECT * FROM tblSystemLang WHERE lVisible = 1 AND lLimitations NOT LIKE '" & Session("ClientId") & "' ORDER BY lId ASC", Conn)
        Try
            Conn.Open()
            reader = cmd.ExecuteReader()
            While reader.Read()
                lId = reader("lId").ToString()
                lLanguage = reader("lLanguage").ToString()
                If Integer.Parse(RqstSession) = Integer.Parse(lId) Then
                    langStr += ("<option value='" & lId & "' SELECTED>") + lLanguage & "</option>"
                Else
                    langStr += ("<option value='" & lId & "'>") + lLanguage & "</option>"
                End If
            End While
        Catch
        Finally
            reader.Close()
            Conn.Close()
        End Try
        Return langStr
    End Function

Try this and let me know......

Hello and thank you for your response. When I use the code I get an error of not using the propery

New

. I get an error for the connection string and then again for closing of the

reader.Close() Conn.Close()

. The error is this

System.NullReferenceException

. I have encountered this error many time and we must close any connection or instance we open. How can I resolve the above 2 problems including the connection string?

Thanks
Awny

Hello and thank you for your response. When I use the code I get an error of not using the propery . I get an error for the connection string and then again for closing of the

reader.Close() Conn.Close()

. The error is this . I have encountered this error many time and we must close any connection or instance we open. How can I resolve the above 2 problems including the connection string?

Thanks
Awny

hey, the two are related problems. Did u add ur connection string on web.config file?

If no means add it under conectionstrings tag.

No I haven't. Since it is a xml file, could you show me how? Thanks, Awny

Hello,

I have tried using the string and every time I run the code the explorer shuts down. I guess there is something wrong. Can you provide me with a piece of code please to figure this out as this is the last piece that is left hopefully.

Thanks
Awny

Hello,

I have tried using the string and every time I run the code the explorer shuts down. I guess there is something wrong. Can you provide me with a piece of code please to figure this out as this is the last piece that is left hopefully.

Thanks
Awny

Paste your code. I will help

<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
  <configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>
  <appSettings />
  <connectionStrings>
    <add
       name="LocalSqlServer"
       connectionString="SERVER=i4selistctrl.db.3931761.hostedresource.com; UID=username goes here;PWD=password goes here;DATABASE=database name"
       providerName="System.Data.SqlClient"
   />
  </connectionStrings>
  <system.web>
    <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.

            Visual Basic options:
            Set strict="true" to disallow all data type conversions 
            where data loss can occur. 
            Set explicit="true" to force declaration of all variables.
        -->
    <compilation debug="true" strict="false" explicit="true">
      <assemblies>
        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Services, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Services.Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
      </assemblies>
    </compilation>
    <pages>
      <namespaces>
        <clear />
        <add namespace="System" />
        <add namespace="System.Collections" />
        <add namespace="System.Collections.Generic" />
        <add namespace="System.Collections.Specialized" />
        <add namespace="System.Configuration" />
        <add namespace="System.Text" />
        <add namespace="System.Text.RegularExpressions" />
        <add namespace="System.Linq" />
        <add namespace="System.Xml.Linq" />
        <add namespace="System.Web" />
        <add namespace="System.Web.Caching" />
        <add namespace="System.Web.SessionState" />
        <add namespace="System.Web.Security" />
        <add namespace="System.Web.Profile" />
        <add namespace="System.Web.UI" />
        <add namespace="System.Web.UI.WebControls" />
        <add namespace="System.Web.UI.WebControls.WebParts" />
        <add namespace="System.Web.UI.HtmlControls" />
      </namespaces>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </controls>
    </pages>
    <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
    <authentication mode="Windows" />
    <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
    <customErrors mode="Off"></customErrors>
    <httpHandlers>
      <remove verb="*" path="*.asmx" />
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
    </httpHandlers>
    <httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </httpModules>
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="OptionInfer" value="true" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>
    </compilers>
  </system.codedom>
  <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <remove name="ScriptModule" />
      <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated" />
      <remove name="ScriptHandlerFactory" />
      <remove name="ScriptHandlerFactoryAppServices" />
      <remove name="ScriptResource" />
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>
</configuration>

Also, could you please tell in the web.config file how to use the below tags as listed in Microsoft (add is listed up in the file code I provided but the clear and remove I dont think they are to be used inside the web file but rather in the vb file just how? by setting the connection to nothing and close or is there anything else?):

<connectionStrings > 
   <add />
   <clear />
   <remove />
</connectionStrings>

Thanks so much and I know I have troubled you so much.

Awny

I am so sorry for nagging but I do need your help in concluding this one as I feel so close in completing this.

Thanks
Awny

Hello,

I have tried using the string and every time I run the code the explorer shuts down. I guess there is something wrong. Can you provide me with a piece of code please to figure this out as this is the last piece that is left hopefully.

Thanks
Awny

Paste your code here. I will help you.

Helllo There,

Here is my code. For the Web.config file it is:

<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
  <configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>
  <appSettings />
  <connectionStrings>
    <add name="ElistConnectionString" connectionString="Data Source=i4selistctrl.db.3931761.hostedresource.com; Initial Catalog=DATABASE NAME; User ID=USER NAME; Password=USER PWD;" providerName="System.Data.SqlClient"/>
  </connectionStrings>

  <system.web>
    <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.

            Visual Basic options:
            Set strict="true" to disallow all data type conversions 
            where data loss can occur. 
            Set explicit="true" to force declaration of all variables.
        -->
    <compilation debug="true" strict="false" explicit="true">
      <assemblies>
        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Services, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Services.Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
      </assemblies>
    </compilation>
    <pages>
      <namespaces>
        <clear />
        <add namespace="System" />
        <add namespace="System.Collections" />
        <add namespace="System.Collections.Generic" />
        <add namespace="System.Collections.Specialized" />
        <add namespace="System.Configuration" />
        <add namespace="System.Text" />
        <add namespace="System.Text.RegularExpressions" />
        <add namespace="System.Linq" />
        <add namespace="System.Xml.Linq" />
        <add namespace="System.Web" />
        <add namespace="System.Web.Caching" />
        <add namespace="System.Web.SessionState" />
        <add namespace="System.Web.Security" />
        <add namespace="System.Web.Profile" />
        <add namespace="System.Web.UI" />
        <add namespace="System.Web.UI.WebControls" />
        <add namespace="System.Web.UI.WebControls.WebParts" />
        <add namespace="System.Web.UI.HtmlControls" />
      </namespaces>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </controls>
    </pages>
    <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
    <authentication mode="Windows" />
    <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->

    <customErrors mode="RemoteOnly"/>

    <httpHandlers>
      <remove verb="*" path="*.asmx" />
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
    </httpHandlers>
    <httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </httpModules>
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="OptionInfer" value="true" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>
    </compilers>
  </system.codedom>
  <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <remove name="ScriptModule" />
      <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated" />
      <remove name="ScriptHandlerFactory" />
      <remove name="ScriptHandlerFactoryAppServices" />
      <remove name="ScriptResource" />
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>
</configuration>

As for the Default.aspx.vb code it is:

Imports System.Data
Imports System.Data.SqlClient

Partial Class _Default
    Inherits System.Web.UI.Page

Public Sub WriteHello()

        Dim myConnection As New SqlConnection
        Dim myCommand As New SqlCommand
        Dim dr As SqlDataReader
        Dim MainId As Integer = 0

        Try
            myConnection = New SqlConnection("Data Source=i4selistctrl.db.3931761.hostedresource.com; Initial Catalog=DATABASE NAME; User ID=USER NAME; Password=USER PWD;")
            'you need to provide password for sql server
            myConnection.Open()
            myCommand = New SqlCommand("SELECT * FROM tblCategories WHERE mainId = 0", myConnection)
            dr = myCommand.ExecuteReader
            While dr.Read()
                'reading from the datareader
                Response.Output.Write("> " & dr("CatAra").ToString() & " - ")
                Response.Output.Write("> " & dr("CatEng").ToString() & " <br /><br /> ")
                'displaying the data from the table
            End While

        Catch
        End Try

        dr.Close()
        myConnection.Close()

        dr = Nothing
        myConnection = Nothing

    End Sub


End Class

Thanks
Awny

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.