Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gridview bind

Status
Not open for further replies.

R7Dave

Programmer
Oct 31, 2007
181
US
Hello

I am receiving an error when trying to bind my gridview. It works fine when I set Autogenerate columns = TRUE

This code works fine at my job but now I'm trying to do my own site using GoDaddy

HTML:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>

<asp:Label ID="user"
runat="server"
Text='<%#Bind("userid")%>'
>
</asp:Label>

</ItemTemplate>
/asp:TemplateField>
</Columns>
</asp:GridView>


This is my server side code...

Sub GetData()
conn.ConnectionString = connectstr
Dim strSQL As String = "select userid from GG_HISTORY where userid='JSMITH' "

Dim Cmd As New SqlClient.SqlCommand
Cmd.Connection = conn
Cmd.CommandText = strSQL
Dim Sql_DA_Request As New SqlClient.SqlDataAdapter
Sql_DA_Request.SelectCommand = Cmd
conn.Open()
Dim Tbl_Request As New DataTable
Sql_DA_Request.Fill(Tbl_Request)
GridView1.DataSource = Tbl_Request
If Tbl_Request.Rows.Count > 0 Then
GridView1.DataBind()
End If
conn.Close()
End Sub

Any help is appreciated -
Thanks
Dave
 
Hello

I found my mistake.

I didn't post an error message because I'm not able to query SQL locally - so I have been uploading my page and receiving a generic error page that tells me to modify my web.config to allow tracing to view the error, etc - I haven't done that yet.

Thanks
Dave
 
I didn't post an error message because I'm not able to query SQL locally - so I have been uploading my page and receiving a generic error page that tells me to modify my web.config to allow tracing to view the error, etc - I haven't done that yet.
you should be testing locally before posting to the production site. either using IIS or VS Web Server.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks Jason - I tried to set it up in IIS but when I try opening a SQL connection I receive the message

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I read posts that made me think this had something to do with using GoDaddy to host - I tried using IIS but still receive the error - I will try looking at my IIS configuration more closely. Thanks again for your help.

Dave

 
are your trying to connect to the production datbase? if so this is the problem.

1. you should never test/develop against a production environment.
2. ISP block access for any computer to access the database. this would create a huge security problem. To remedy this ISP only allow there web servers to communicate with there database servers.

if you need a database to test against download SqlExpress and install on your machine. then code against this database. By programming to the interfaces of ADO.Net (or using an ORM framework) you can seamlessly access a variety of databases without changing a single line of code. (this is done through config files).

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top