Trouble Connecting To MSSQL DB Using VB.NET

Posted on 2008-10-22
Last Modified: 2011-10-19
I get this error when I try to run the attached code:

BC30455: Argument not specified for parameter 'Number' of 'Public Function Str(Number As Object) As String'.

I'm not sure what's up with it. Any ideas?  Thanks for reading.

Imports System.Data.SqlClient

Imports System.Data

Partial Class traf

    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)


        Dim str3 As String

        str3 = ConfigurationManager.ConnectionStrings("traffic").ConnectionString()

        Dim conn3 As SqlConnection

        conn3 = New SqlConnection(str)

        Dim sqlSelect3 As String

        sqlSelect3 = "SELECT * FROM activecams"

        Dim cmd3 As SqlCommand

        cmd3 = New SqlCommand(sqlSelect3, conn3)

        cmd3.CommandType = CommandType.Text

        Dim dr3 As SqlDataReader



            dr3 = cmd3.ExecuteReader()

            If (dr3.HasRow) Then

                While dr3.Read()

                    If dr3("cams") = 19 Then

                        Label5.Text = "19,19"

                    End If

                End While

        Catch ex As Exception



        End Try

    End Sub

    End Sub

End Class


<%@ Page Language="VB" MasterPageFile="MasterPage2.master" AutoEventWireup="true"  CodeFile="~/trafficcam.aspx.vb" Inherits=traf

    Title="Untitled Page"  %>

<%@ Register Assembly="Ektron.Cms.Controls" Namespace="Ektron.Cms.Controls" TagPrefix="CMS" %>

<asp:Content ID="Content8" ContentPlaceHolderID="MenuPlaceHolder"  runat="Server">

        function camName(camnumber) {

            switch (camnumber) {

                case 1:

                    camname = "Broad & Mercury";


                case 2:

                    camname = "Broad & Church";


                case 3:

                    camname = "Broad & Main";


                case 4:

                    camname = "Broad & West College";


                case 5:

                    camname = "I-24 & Old Fort";


                case 6:

                    camname = "Old Fort & Chaffin";


                case 7:

                    camname = "Old Fort & Bridge";


                case 8:

                    camname = "Old Fort & Kings Hwy";


                case 9:

                    camname = "NW Broad & Monte Hale";


                case 10:

                    camname = "NW Broad & Thompson";


                case 11:

                    camname = "Memorial & Lokey";


                case 12:

                    camname = "Memorial & Clark";


                case 13:

                    camname = "Memorial & Northfield";


                case 14:

                    camname = "Church & CSX RR";


                case 15:

                    camname = "Church & Middle Tennessee Blvd";


                case 16:

                    camname = "Church & I-24";


                case 17:

                    camname = "Church & Warrior";


                case 18:

                    camname = "Church & Calumet";


                case 19:

                    camname = "Church & Barfield";



                    camname = "";



            return (camname);


        function camOpen(camnumber, camactive) {

            if (typeof camwin != 'undefined') { camwin.close(); }

            camwin ="", "Camera", "toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=370,height=280");

            var vidserv = Math.round((camnumber / 4) + .49);

            var cam = camnumber % 4;

            if (cam == 0) { cam = 4; }

            var ImageResolution = "352x240"; var DisplayWidth = "352"; var DisplayHeight = "240";

            var File = "axis-cgi/mjpg/video.cgi?resolution=" + ImageResolution + "&duration=60";

            var output = "";

            var camname = camName(camnumber);

            var Camera = cam;

            if (camactive == 0) { Camera = 4; vidserv = 5 }

            var BaseURL = "http://traf" + vidserv + "";

            if (Camera != "") { File += "&camera=" + Camera; } output = '<html><head><title>Camera ' + camnumber + '</title></head><body><font size="2" face="Verdana, Arial, sans-serif"><STRONG>' + camname + '</STRONG></font><br>';

            if ((navigator.appName == "Microsoft Internet Explorer") && (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k")) {

                output += "<OBJECT ID=\"CamImage\" WIDTH="

                output += DisplayWidth;

                output += " HEIGHT=";

                output += DisplayHeight;

                output += " CLASSID=CLSID:917623D1-D8E5-11D2-BE8B-00104B06BDE3 ";

                output += "CODEBASE=\"";

                output += BaseURL;

                output += "activex/,0,2,15\">";

                output += "<PARAM NAME=\"URL\" VALUE=\"";

                output += BaseURL;

                output += File;

                output += "\"> <BR><STRONG>Axis ActiveX Camera Control</STRONG><BR>";

                output += "The AXIS ActiveX Camera Control, which enables you ";

                output += "to view live image streams in Microsoft Internet";

                output += " Explorer, could not be registered on your computer.";

                output += "<BR></OBJECT>";


            else {

                output = "<IMG SRC=\"";

                output += BaseURL;

                output += File;

                output += "&dummy=garb\" HEIGHT=\"";

                output += DisplayHeight;

                output += "\" WIDTH=\"";

                output += DisplayWidth;

                output += "\" ALT=\"Moving Image Stream\">";


            output += "</center></body></html>"





    <cms:smartmenu id="SmartMenu1" runat="server" defaultmenuid="144" enablemouseoverpopup="True"

        stylesheet="vert_popupmenu_workarea_vista.css" />


<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

    <html xmlns="">

    <p align="CENTER">

    <asp:label id=label5 Visible=false runat=server  Text=""> </asp:label>



        <img name="cameramap" src=""

            width="360" height="546" border="0" usemap="#m_cameramap" alt="">

        <map name="m_cameramap">

            <area shape="rect" accesskey="test" id="test" coords="193,524,225,543" href="javascript:camOpen(<%response.write(label5.text) %>)"

                title="Church & Barfield" alt="Church & Barfield">  

            <area shape="rect" coords="199,469,231,488" href="javascript:camOpen()" title="Church & Calumet"

                alt="Church & Calumet">

            <area shape="rect" coords="12,169,44,188" href="javascript:camOpen()" title="I-24 & Old Fort"

                alt="I-24 & Old Fort">

            <area shape="rect" coords="60,178,92,197" href="javascript:camOpen()" title="Old Fort & Chaffin"

                alt="Old Fort & Chaffin">

            <area shape="rect" coords="106,185,138,204" href="javascript:camOpen()" title="Old Fort & Bridge"

                alt="Old Fort & Bridge">

            <area shape="rect" coords="176,179,208,198" href="javascript:camOpen()" title="Old Fort & Kings Hwy"

                alt="Old Fort & Kings Hwy">

            <area shape="rect" coords="199,397,231,416" href="javascript:camOpen()" title="Church & Warrior"

                alt="Church & Warrior">

            <area shape="rect" coords="229,389,261,408" href="javascript:camOpen()" title="Church & I-24"

                alt="Church & I-24">

            <area shape="rect" coords="221,283,253,302" href="javascript:camOpen()" title="Church & Samsonite"

                alt="Church &amp; Middle Tennessee Boulevard">

            <area shape="rect" coords="222,249,254,268" href="javascript:camOpen()" title="Church & CSX RR"

                alt="Church & CSX RR">

            <area shape="rect" coords="210,178,242,197" href="javascript:camOpen()" title="Broad & Main"

                alt="Broad & Main">

            <area shape="rect" coords="260,228,292,247" href="javascript:camOpen()" title="Broad & Mercury"

                alt="Broad & Mercury">

            <area shape="rect" coords="232,202,264,221" href="javascript:camOpen()" title="Broad & Church"

                alt="Broad & Church">

            <area shape="rect" coords="185,142,217,161" href="javascript:camOpen()" title="Broad & West College"

                alt="Broad & West College">

            <area shape="rect" coords="220,127,252,146" href="javascript:camOpen()" title="Memorial & Lokey"

                alt="Memorial & Lokey">

            <area shape="rect" coords="149,71,181,90" href="javascript:camOpen()" title="NW Broad & Monte Hale"

                alt="NW Broad & Monte Hale">

            <area shape="rect" coords="86,11,118,30" href="javascript:camOpen()" title="NW Broad & Thompson"

                alt="NW Broad & Thompson">

            <area shape="rect" coords="239,97,271,116" href="javascript:camOpen()" title="Memorial & Clark"

                alt="Memorial & Clark">

            <area shape="rect" coords="251,60,283,79" href="javascript:camOpen()" title="Memorial & Northfield"

                alt="Memorial & Northfield">




Open in new window

Question by:thedeal56
  • 2
LVL 47

Accepted Solution

Wayne Taylor (webtubbs) earned 500 total points
ID: 22776716
Simple typo. You used "str" instead of "str3"....

    conn3 = New SqlConnection(str3)


Author Comment

ID: 22776734
Ah, I looked at that several times and never saw it.  Thank you.
LVL 13

Expert Comment

ID: 22776761
I dont find a declaration for str in the code. Are you trying to pass str3?
Also check what is the value of str  here

conn3 = New SqlConnection(str)

LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 22776903

I assume you have Option Explicit turned off? I thoroughly recommend you turn it back on. The typo would have been immediately obvious had it been on.

To turn it on, go to Tools > Options > Projects and Solutions > VB Defaults.


Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now