 |
| ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 11th, 2006, 11:30 AM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Public Class Data
Public Function ProjMain() As DataSet
Dim objData As ConnectSql
Dim objcom As SqlCommand
Try
objData = New ConnectSql
objData.CreateCommand(objcom, CommandType.StoredProcedure, "ProjMain")
ProjMain = objData.CreateDataset("Data", objcom)
objcom.ExecuteReader()
Catch ex As Exception
End Try
End Function
end class
venkat
|
|

December 11th, 2006, 11:36 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
If you remove your Try Catch block this code is almost certainly throwing an error. You never call your connection string from your webconfig file nor do you return anything. The code your provided executes as a method, not a function.
DataTable getDataTable()
{
DataTable tempDT = new DataTable();
daSql = new SqlDataAdapter();
sqlCmd = new SqlCommand();
sqlConn = new SqlConnection();
daSql.SelectCommand = sqlCmd;
sqlCmd.Connection = sqlConn;
sqlConn.ConnectionString = ConfigurationSettings.AppSettings("ConnectionStrin g");
sqlCmd.CommandText = [SQL Statement];
daSql.Fill(tempDT);
return tempDT;
}
That code returns a datatable.
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|

December 12th, 2006, 03:40 AM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i'm beginner in ASP.net pl. explain ur code
i enter ur code
but error : declaration expected
|
|

December 12th, 2006, 03:57 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Just try the code below, it should work for you:
Dim sConn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
Dim sQuery As String = "spTest"
sConn.Open()
Dim sqlCmd As SqlCommand = New SqlCommand(sQuery,sConn)
sqlCmd.CommandType = CommandType.StoredProcedure
Dim da As SqlDataAdapter = New SqlDataAdapter(sqlCmd)
Dim ds As DataSet = New DataSet()
da.Fill(ds)
DataGrid1.DataSource = ds
DataGrid1.DataBind()
sConn.Close()
Regards
Mike
Fortune favours the brave, so don't regret on missed oppurtunities.
|
|

December 12th, 2006, 04:07 AM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
mike, where is put ur code
|
|

December 12th, 2006, 04:28 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Friend,
Don't mind, I guess first you need to study some programming basics, and then move to .net.
Anyways, the code I gave you can be put wherever you wish to bind the datagrid, say on page_load.
Regards
Mike
Fortune favours the brave, so don't regret on missed oppurtunities.
|
|

December 12th, 2006, 09:27 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
The declartaion error that my code throws is because, in my code that I supplied, I do not declare my Sql objects in that function; I thought it was obvious that one would need to delare the objects to use that function.
I understand that you are a beginner to .NET and I applaud you for wanting to learn, however, I agree with Mike here. It seems that you need to study some programming basics before you start in on hard core .NET programming. I suggest picking up a book or reading any of the various resources that come up on google to get you started.
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|

December 12th, 2006, 10:22 AM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Mike & Dparson ur guidance
|
|

December 14th, 2006, 03:55 AM
|
|
Registered User
|
|
Join Date: Dec 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Please send us code dat u have wrote for binding data
ragards
Pravin Patil
|
|

December 14th, 2006, 04:06 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Dim sConn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
Dim sQuery As String = "spTest"
sConn.Open()
Dim sqlCmd As SqlCommand = New SqlCommand(sQuery,sConn)
sqlCmd.CommandType = CommandType.StoredProcedure
Dim da As SqlDataAdapter = New SqlDataAdapter(sqlCmd)
Dim ds As DataSet = New DataSet()
da.Fill(ds)
DataGrid1.DataSource = ds
DataGrid1.DataBind()
sConn.Close()
Regards
Mike
Fortune favours the brave, so don't regret on missed oppurtunities.
|
|
 |