Getting a DNS error, can someone help - please?

T

Teep

Below is my code for dropdownlist that is populated from a SQL table.
After a selection from the ddl, a datagrid is suppose to come up
pertaining to the information selected, but I keep getting a DNS
error. I developed this "simple" page but so far it is not simple!
argh!



<%@ Page Language="VB" Debug="true" Explicit="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SQLClient" %>
<script runat="server">

Dim strConn as string =
"server=abcdserver;database=acct_payable;trusted_connection=true"

Sub Page_Load(Source as Object, E as EventArgs)
if not Page.IsPostBack then
doData()
end if
End Sub




Sub doQuery(Source as Object, E as EventArgs)
'Sub doQuery is for the datagrid
'This may be the source of DSN errors - the sql statement
Dim supname as string
Dim MySQL = "SELECT splr_name, splr_name, splr_addr, " & _
"splr_city FROM tbl_ap_vendors WHERE splr_name='" & supname &
"'"
Dim MyConn as New SQLConnection(strConn)
Dim ds as DataSet=New DataSet()
Dim Cmd as New SQLDataAdapter(MySQL,MyConn)
Cmd.Fill(ds,"tbl_ap_vendors")

'MyDataGrid is for the datagrid to fill
MyDataGrid.Datasource=ds.Tables("tbl_ap_vendors").DefaultView
MyDataGrid.DataBind()
End Sub


Sub doData()
'Sub doData is for the dropdownlist
Dim strSQL =
"server=abcdserver;database=acct_payable;trusted_connection=true"

Dim Conn as new SQLconnection(strConn)
strSQL = "select splr_name from tbl_ap_vendors ORDER BY
splr_name"
Dim Cmd as New SQLCommand(strSQL,Conn)
Conn.Open()
MyDropDownList.DataSource = Cmd.ExecuteReader()
MyDropDownList.DataBind()
End Sub


Function FixDR (sItem) as String
'Function FixDR is for null fields
if Not sItem is System.DBNull.Value then FixDR=sItem
End Function

</script>
<html>
<head>

<title>Testing a dropdownlist and datagrid</title>
</head>
<body>


<Form id="form1" runat="server">
<div align="center"><table> <tr>

</tr>
<tr>
<!-- HTML code to display the DropDownList on the screen for user
input
list is populated by a SQL table and selection bring up DataGrid -->
<td align="center" valign="Top" Colspan="2"><hr>
<b><i><font Color="#0000FF">Using a DropDownList and a
DataGrid:</font></i></b>
<asp:DropDownList id="MyDropDownList" datatextfield="splr_name"
runat="server" />
<asp:Button id="button" Text="Select Supplier Name" onClick="doQuery"
runat="server" />


<!-- HTML code to display the DataGrid on the screen selection is
determined from user
input selection from DropDownList -->
<asp:Datagrid
Id="MyDataGrid"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false">
</asp:DataGrid>
</td>
</tr>
</table></div>
</Form>



</body>
</html>
 
K

Kevin Spencer

....and the error is? And the line of code it points to is?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
T

TN Bella

Thanks for looking at my post.

The SubdoQuery may be the source of the error - I posted that in my
code. The program runs the first half the ddl, and after the button is
clicked a generic DNS error page comes up - "the page cannot be
displayed."

Actually, on the bottom of the page it says: "Cannot find server or DNS
Error." No other error code, like 400s or 500s.


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
K

Kevin Spencer

That error code indicates that the web server specified in your URL does not
exist (for example, if you mis-typed "http://microsoft.com" as
"http://micorsoft.com", or that a DNS error has occurred which prevents the
browser from being able to resolve the IP address of the server. What does
the URL for the page look like in the address bar of your browser?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
K

Kevin Spencer

Does your machine have a hosts entry for "localhost?" Try manually typing in
the URL in your browser, and substitute the machine name (or 127.0.0.1) for
"localhost" and see if you get the same error. What development environment
are you using?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
T

TN Bella

Thanks for your help. My error is now fixed, I just retyped the code
again and boom it worked! I appreciate all your time and patience with
this situation.

Tina

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Joined
Jul 27, 2006
Messages
1
Reaction score
0
DNS Error -- Solution?

I had exactly the same error with my Datagrid trying to display data from a dataset which I built. I displayed fine, but as soon as I tried to run SQL updates on the rows, I kept getting the DNS Error you were talking about. I then decreased the amount of rows in the dataset, and it worked fine. I think that somewhere in the dataset there is a little bug that has something to do with the amount of rows in the dataset.

Just a guess?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top