|
-
Dec 12th, 2003, 11:07 AM
#1
Thread Starter
Lively Member
Need step-by-step SQL help
So my VB book only shows how to setup an SQL query at design time. I need to do it at run time.
My program is just a little thing that allows a person to copy a file from their desktop to the network. The user would put the filename to be copied in a textbox. There is an Access database sitting on the network that maps all the files to particular directories. So when the user clicks on submit, the program looks up what directory to put it in and copies it. I'm stuck on looking up the directory to put it in.
For development purposes, I have a copy of the Access database on my harddrive.
I know I need a connection, a data adapter, and a dataset. How do I connect to the database on my hard drive? I've looked at a lot of code in other threads here, but I am lost. I think I need something like (this is just off the top of my head, I haven't tried this):
VB Code:
Dim dir As String
Dim conn As New SqlConnection("c:\DB\SRCDATA.MDB")
Dim query As String = "SELECT LockDirectory FROM MstrFileList WHERE MstrFileName = " & TextBox1.Text
Dim cmd = New SqlCommand(query, conn)
conn.Open()
dir = cmd.ExecuteNonQuery()
conn.Close()
MsgBox("The directory is " & dir)
As I said, I haven't actually tried this yet because I am so lost. Am I even on the right track? If this is completely off, could someone kind of step me through it?
Can I put the path in the SqlConnection?
Will the concatenation for query work?
Did I declare cmd properly?
Can I assign the cmd.ExecuteNonQuery to dir like that? Is the ExecuteNonQuery even correct?
?????
Thanks
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
|