Sorry, I missed your post earlier, I had a few other things on my mind as you can probably witness from my thread from earlier today
Is CodeExamples a sub-folder of Projects? If so, then this is your problem. If not, I’m dumb founded, although there has to be a reason for it, I’m just not coming up with anything at the moment.
I am new to the .NET arena and I am getting the above compile error when trying to compile the addressbookDS.aspx page, (Chptr 10 pp. 372 - 374). It works when I use the Access DB code, but does not for MSDE. I prefer MS SQL and would like to get it to work. I viewed a previous posting addressing a similar issue, but it looks like it does not apply to my circumstance. The code in question follows;
Dim objConn = New SqlConnection(“Server=griwi03-d600\NETSDK;Database=DORKNOZZLE;User ID=sa;Password=PASSWORD”)
Dim objDA As SqlDataAdapter
Dim objDS As New DataSet()
Sub Page_Load()
If Not IsPostBack Then
BindData()
End If
End Sub
Sub BindData()
objDA = New SqlDataAdapter(“SELECT * FROM Employees”, objConn)
objDA.Fill(objDS, “Employees”)
objDA.SelectCommand = New SqlCommand("SELECT * FROM Departments", objConn)
objDA.Fill(objDS, "Departments")
The compilation error is;
Source Error:
Line 22:
Line 23: Sub BindData()
Line 24: objDA = New SqlDataAdapter(“SELECT * FROM Employees”, objConn)
Line 25: objDA.Fill(objDS, “Employees”)
Line 26:
I bought the book “Build Your Own ASP.NET Website Using C# & VB.NET” (April 2004 version)
I had the same problem with chapter 10 and 11, that many poeple have here.
This is the common problem for the both…
I asked Zak about this problem.
He didn’t answer me not at all !
It seems he does’t want to take any responsability for his book !
I waste 12 hours to solving this problem and I found that this code works for Oledb (Access), but does not work for SqlClient…
I arranged the code for files addressbookDS.aspx (chapter 10) and global.asax (chapter 11) and now it’s working for SqlClient too.
I changed this part of code:
objDA = New SqlDataAdapter("SELECT * FROM Employees", objConn)
objDA.Fill(objDS, "Employees")
objDA.SelectCommand = New SqlCommand("SELECT * FROM Departments", objConn)
objDA.Fill(objDS, "Departments")
To this (changes in bold):
[B]Dim cmd As New SqlCommand("SELECT * FROM Employees", objConn)[/B]
objDA = New SqlDataAdapter([B]cmd[/B])
objDA.Fill(objDS, "Employees")
objDA.SelectCommand = New SqlCommand("SELECT * FROM Departments", objConn)
objDA.Fill(objDS, "Departments")
I am newbe in ASP.NET, so I dont know if it’s correct to do so, but at least it works.
This problem is magor for this book.
I think that Zak Ruvalcaba, have to pay attention to this topic, bcs he got the money and has to be responsable for his underdone book…