|
-
Jun 6th, 2010, 01:42 PM
#1
Thread Starter
New Member
running stored procedure
I am a VB newb running VB/VS 2010.
I am trying to call a stored procedure from a SQLExpress2005 data base on a Windows 2003 Domain Controller. I keep having errors when I run my code in debug mode.
Stored procedure name = InsertUsersFromAD
Server name where SQL resides = MIS631
Database Name = AdminGUI
I have ******** rights on the dev PC and the servers
My code is as follows:
'Run Stored Procedure on SQL Database
vb.net Code:
Dim CONN As New SqlConnection
CONN.ConnectionString = "Data Source = \\MIS631; Initial Catalog = AdminGUI; " & "Integrated Security = True"
Dim sc As New SqlCommand("InsertUsersFromAD", CONN)
sc.CommandType = CommandType.StoredProcedure
CONN.Open()
sc.ExecuteNonQuery()
sc.Connection.Close()
I've tried making the Data Source = \\MIS631\SQLEXPRESS also, which didn't seem to work. Please help!!
I am trying to finish up a school project and this is the only thing not working.
Thanks so much.
-
Jun 6th, 2010, 04:51 PM
#2
Re: running stored procedure
I keep having errors when I run my code in debug mode.
Tell us what the errors are and which line they are thrown on and we might be able to help
-
Jun 6th, 2010, 05:09 PM
#3
Re: running stored procedure
there's no username or password in your connection string? you can also remove the "&" between the 2 parts of the connection string. They can be combined.
www.connectionstrings.com
-
Jun 6th, 2010, 05:19 PM
#4
Re: running stored procedure
You dont have to use a username and password when you use Integrated Security because it means that it uses Windows Authentication (ie uses your logged on user credentials).
I'm also pretty sure you dont need the \\ when specifying the server, but you will definitely need the \SQLEXPRESS bit if it is a default setup of SQL Express on the server. Its pretty hard to suggest things though when we dont know where it is failing - I mean it might be connecting to the server fine, just throwing an error when he tries to do ExecuteNonQuery
-
Jun 6th, 2010, 05:57 PM
#5
Thread Starter
New Member
Re: running stored procedure
I apologize for not providing needed information, like I said I'm a newb.
I get an SQLException was unhandled -- error 25
when it hits the line
CONN.Open()
-
Jun 6th, 2010, 06:10 PM
#6
Thread Starter
New Member
Re: running stored procedure
OK, I took off the preceeding "\\" before the server name.
"Now i get a SQLException error was unhandled" message at the same line, but is says that the user is not associated with a trusted SQL server connection.
I am a domain admin, server admin, sql admin, local workstation admin.
So the error changed slightly, but the code still hangs at the same line.
-
Jun 6th, 2010, 06:39 PM
#7
Re: running stored procedure
Are you 100% sure that your windows user account that you are logged on with actually has permission to access that SQL database though? Just because you are a domain admin doesnt necessarily mean you have permission to every single database within an SQL instance. Also, assuming this application is going to be for more people than just yourself to use, have you thought about if they are going to have permission to the database as well?
Just to test to see if it is a permissions issue, see if you can log in to the SQL instance via SQL Management Studio using your windows credentials.
-
Jun 6th, 2010, 06:48 PM
#8
Thread Starter
New Member
Re: running stored procedure
Yes sir. I assure you that I can log into the database with my credentials. I can also browse through server objects from my client PC that is running VB using the Server Explorer. I have also checked the firewalls
-
Jun 6th, 2010, 07:01 PM
#9
Re: running stored procedure
Hmm ok well just try this code exactly as it is and see if you still get an exception on the call to CONN.Open()
Code:
Dim CONN As New SqlConnection("Server=MIS631\SQLEXPRESS; Database=AdminGUI; Trusted_Connection=True;")
CONN.Open()
-
Jun 6th, 2010, 07:16 PM
#10
Thread Starter
New Member
Re: running stored procedure
THAT DID IT!!
Thanks so much. I have never used VB before and my first attempt is for an application that I am making for my Masters project. I am basically writing a new interface for AD Users and Computers, it is a very grandiose attempt for my first time programming.
THANKS SO MUCH!!
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
|