|
-
Aug 4th, 2004, 05:00 AM
#1
Thread Starter
PowerPoster
CommandText not initialized?
Hi there,
I am trying to get data back from SQL but i always get this error. What does it mean and how do I sort it?
CommandText property has not been initialized
Code:
Dim SQLCommand As New SqlClient.SqlCommand
Dim sqlconn As New SqlClient.SqlConnection(ConnectionString)
sqlconn.Open()
SQLCommand.Connection = sqlconn
Dim SQLDataAdapter As New SqlClient.SqlDataAdapter
SQLDataAdapter.SelectCommand = New SqlClient.SqlCommand(query, sqlconn)
Dim SQLDataSet As New DataSet
SQLDataAdapter.Fill(SQLDataSet)
Dim SQLConnection As New SqlClient.SqlCommand(query, sqlconn)
'we have the query ready in a string
SQLCommand.ExecuteNonQuery()
after that has been solved...I would also like to know how do i display the results on the screen? (im using asp.net btw....)
Thanks
-
Aug 4th, 2004, 08:02 AM
#2
I wonder how many charact
[list=1]
VB Code:
[*]Dim SQLCommand As New SqlClient.SqlCommand[*]Dim sqlconn As New SqlClient.SqlConnection(ConnectionString)[*]Dim SQLDataAdapter As New SqlClient.SqlDataAdapter[*] SQLDataAdapter.SelectCommand = New SqlClient.SqlCommand(query, sqlconn)[*]Dim SQLDataSet As New DataSet[*]SQLDataAdapter.Fill(SQLDataSet)[*]Dim SQLConnection As New SqlClient.SqlCommand(query, sqlconn)[*]SQLCommand.ExecuteNonQuery()
[/list=1]
DataAdapter objects are just a series of sqlCommand objects... so I suspect your Select command on your DataAdapter is flunked. Try running the wizard again, or inspecting the Wizard-generated code in the Designer section.
-
Aug 4th, 2004, 08:14 AM
#3
Thread Starter
PowerPoster
thanks, seems to work now
another Q is - displaying the data.
I am using a datalist now (new at all of this btw) and in order to display the records, some of the fields do not exist in the SQL table database but have been joined from other tables/fields etc... - the code was not done by me.
so how do i tell it in the datalistview to display that type of data? because if i do:
..['mts.media_type']"
it chucks an error
but if a field is there in that table like owner then it will work
any ideas?
is there a better way of viewing the results on the page?
-
Aug 4th, 2004, 05:43 PM
#4
I wonder how many charact
I'm guessing the dataset (or a table of that dataset) you are binding to does not contain these extra fields correct?
What I would need to know is where the other fields are coming from: Are they coming from a DataTable you have created...read from file... etc...
For many operations, you can begin by executing the DataSet Merge method on whatever data container you are trying to incorporate... as illustrated in the following MSDN reference:
http://msdn.microsoft.com/library/de...mergetopic.asp
For other operations, you may need to systematically loop through the corresponding rows in the two sources, and build a new one by using for-loop and adding new rows to a new datatable.
In any case, the MSDN reference should be a start. Without further details, it is hard to suggest the proper method of attacking the data.
-
Aug 4th, 2004, 05:50 PM
#5
Thread Starter
PowerPoster
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|