|
I recently bought a MSDN Visual Studio 2005 Professional Subscription and I am trying to learn VB.NET, specifically how to do use the ADO.NET stuff for database operations.
I have bought a reference book titled “Beginning VB.NET 2003” and I’m trying out this example:
'Import Data and SqlClient namespaces
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Dim objConnection As SqlConnection = New SqlConnection("server=(local);database=pubs;user id=sa;password=")
Dim objDataAdapter As New SqlDataAdapter()
Dim objDataSet As DataSet = New DataSet()
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Set the SelectCommand properties...
objDataAdapter.SelectCommand = New SqlCommand()
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter.SelectCommand.CommandText = _
"SELECT au_lname, au_fname, title, price " & _
"FROM authors " & _
"JOIN titleauthor on authors.au_id = titleauthor.au_id " & _
"JOIN titles ON titleauthor.title_id = titles.title_id " & _
"ORDER BY au_lname, au_fname"
objDataAdapter.SelectCommand.CommandType = CommandType.Text
'Open the database connection...
objConnection.Open()
'Fill the DataSet object with data...
objDataAdapter.Fill(objDataSet, "authors")
'Close the database connection
objConnection.Close()
'Set the DataGrid properties to bind it to our data...
grdAuthorTitles.DataSource = objDataSet
grdAuthorTitles.DataMember = "authors"
'Cleanup
objDataAdapter = Nothing
objConnection = Nothing
End Sub
End Class
I’m getting an error on this line:
Dim objConnection As SqlConnection = New SqlConnection("server=(local);database=pubs;user id=sa;password=")
The SqlConnection statement after the New is giving me the error “Type ‘SqlConnection’ is not defined.”
Can anyone tell me why this is happening? The contructor for the data operations are imported at the beginning of the project. I have no idea what is wrong, or how to correct it.
Thank you,
Quecumber256
|
|
|
|
|
The namespace imported is correct so you might want to check whether the project has a reference to System.Data (System.Data.dll). If there is none, just add a reference to it by going to Project > Add Reference (if you are using Visual Studio) and choose System.Data or System.Data.SqlClient.
Or, if it still doesn't work, try typing the fullname of SqlConnection class (System.Data.SqlClient.SqlConnection) instead.
Hope that helps.
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
Hi Edbert,
Doesn't the Imports System.Data and Imports System.Data.SqlClient take care of this for you? The code I included in the question is exactly like that in the Beginning VB.NET 2003 referance book. There where no instructions in the 'Try-it-out' to add such a referance.
Thank you,
Quecumber256
|
|
|
|
|
Did you use the VS2003 provided by the book?
It might be that the VS2003 version is an older one, therefore you might want to try System.Data.Sql instead of System.Data.SqlClient.
I'm quite sure it's a namespace problem, so check that you have added the correct references and imported the correct namespace (use the intellisense).
Otherwise, try Resharper[^]. It usually finds the correct class and namespace for you to use.
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
Hi. I have a project at the university to do a booking systems. Booking is done by telephone (telesales) and online. Can someone please help me or give me some advice
|
|
|
|
|
|
Hi All,
I want to save multiple .bmp images one by one.
The code is in vb.net.
Now my problem is that when I save the image I get error message as
'The File is being accessed by another process'
Can u plz tell me how to set free the image from that other process (which is not known).
Thanks in advance
Born to code
|
|
|
|
|
ganesh_nagargoje wrote: I get error message as 'The File is being accessed by another process'
are you sure the message isn't this one ?
<font color=red>Please do NOT post programming questions or ads to this forum.</font>
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
ganesh_nagargoje wrote: Can u plz tell me how to set free the image from that other process (which is not known).
You'll need one of these[^].
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
If your OS is WinXP, you should wait for SP4. For the rest of windows OSes, a simple reboot should solve your problems. If you code for Vista, my advice is to wait for the release version, don't spend much time checking weird bugs which can occur in betas.
|
|
|
|
|
Look here[^]
You know you're obsessed with computer graphics when you're outside and you look up at the trees and think, "Wow! That's spectacular resolution!"
Only kings, presidents, editors, and people with tapeworms have the right to use the editorial "we."
|
|
|
|
|
|
You other guys are weak you know, a forum is a forum, if you cant help and only make stupid answer, please drop dead .
Ok, now the bmp saving, could you tell me, whats the exact point of the program, do you select some images somehwere which are copied to BMp in another place?
Be more exact please, else i can't help.
You mess with the best, you die like the rest... well... kinda???
|
|
|
|
|
THe post was moved from the Lounge to the VB.NET forum, where it belongs. Programming questions are strictly forbidden in the Lounge. Violators will be violated, by all kinds of vile Loungers.
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 11:26 Tuesday 20th June, 2006
|
|
|
|
|
The "other process" is probably your own app. I'm guessing that you loaded the image into a PictureBox using a FromFile method?
When you load an image using the FromFile method, the file is locked and stays open for the life of the Image object. You can find a workaround for this little "feature" here[^] on MSDN.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I have 2 datagrids: order and orderDetail
I also have a dataset with 2 tables (order & orderDetail) and a relation between them
the order-datagrid is bind to the order-table in my dataset.
The orderDetail-datagrid is bind to the relation between the 2 tables.
So when I click on a row in the order-datagrid, the orderDetail-datagrid will automatically display the corresponding detail-records.
When I select a row in the Order-datagrid by using code:
dgOrder.select(rowNumber)
The orderDetail-datagrid does NOT display the detail of the newly selected order, he keeps displaying the detail of the previous selected order.
Does anyone know how i can achieve, that the orderDetail-datagrid is refreshed with the detail of the order that was selected by code.
Any help is much appreciated,
Thanks in advance
John
|
|
|
|
|
Solved:
setting the 'CurrentrowIndex' does the job
|
|
|
|
|
HI to everyone....
I try to make an application, taking some mdb files from a directory and connect them with my rpt files.
I made that and everything is ok till the time that it try to logo into the 65th mdb..........
It shows me an exception "Logon failed" !!!!!!!!!!
I try everything and i think the problem is in the tbl.ApplyLogOnInfo, i think runs only for 64 times...
Does anyone knows something about that and help me?????
Is there anyway to reset it????
giotis
|
|
|
|
|
i want to create treeview which contain different images for different nodes... like this,,, but i dont know how to do it,,,
plz.. help me if you can solve my problem,,,
manisha
|
|
|
|
|
Hello there!
To add images for the Tree nodes you have to first create an ImageList. Add as many images as u want in the ImageList and then assign the ImageList object to your TreeView Control ImageList property.
Use the following statement to add the image against a node.
<br />
TreeViewControl.Nodes(0).SelectedImageIndex = 0<br />
So this will assign an image located at 0 index of ImageList to the 0th node of the tree view.
Hope this helps
regards
Mubashir
Storan Technologies USA.
|
|
|
|
|
thank you ,, mubashir,, for kind help
|
|
|
|
|
How to put registration code in VB6.0 software?
|
|
|
|
|
If you mean the registartion info of VB6... That will be putted in while installing, else try to go the Help and select Register. (I dont know, i only remeber vb6 needed Registartion info on install).
You mess with the best, you die like the rest... well... kinda???
|
|
|
|
|
Can you be more specific?! What kind of registration are you talking about?
----
www.digitalGetto.com
|
|
|
|
|
hi everybody
I am working on visual basic 6.0 with microsoft visio 2003.i have toolbar which is appear in visio window, all the thing works perfectly.when i open visio it is in the center of the page i docked it somewhere on the page and it works
Now i want that when i open visio this toolbar is already docked.
if anyone know Please help me
Thanks
Thanks
|
|
|
|