Go Back   Access World Forums > Apps and Windows > VB.NET

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 10-26-2012, 12:13 PM   #31
AccessMSSQL
Seasoned Programmer-ette
 
Join Date: May 2012
Location: Los Angeles, California
Posts: 636
Thanks: 1
Thanked 111 Times in 109 Posts
AccessMSSQL will become famous soon enough AccessMSSQL will become famous soon enough
Re: Question About Some Code

I'm at a loss at this point. You could try one more thing - login to the SQL Server machine with the windows domain account you are logging in with when you test and experience the error. Then try to connect to the SQL Server. Also, in the web.config your connectionstring is referencing the IP address of the SQL Server? Maybe you need to put the actual name in?

__________________
Cheryl

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

***********************
please mark threads complete if issue is resolved!
AccessMSSQL is offline   Reply With Quote
Old 10-26-2012, 12:16 PM   #32
jcruzAME
Newly Registered User
 
Join Date: Oct 2011
Posts: 135
Thanks: 1
Thanked 0 Times in 0 Posts
jcruzAME is on a distinguished road
Re: Question About Some Code

Join the club! I think we've tried to put in the server name and it didn't work. I will try that again.
jcruzAME is offline   Reply With Quote
Old 10-26-2012, 12:18 PM   #33
AccessMSSQL
Seasoned Programmer-ette
 
Join Date: May 2012
Location: Los Angeles, California
Posts: 636
Thanks: 1
Thanked 111 Times in 109 Posts
AccessMSSQL will become famous soon enough AccessMSSQL will become famous soon enough
Re: Question About Some Code

Here's how one of my connection strings are setup - maybe take a look and see if you need to change yours?
Code:
<add name="MyConn" connectionString="Data Source=SQLServer;Initial Catalog=MyWebsiteDatabase;Persist Security Info=True; User ID=webuser;Password=webpassword;MultipleActiveResultSets=True"
      providerName="System.Data.SqlClient" />
I see your connection string doesn't have providerName and the database reference you have is server=. Try modify to the above format?

__________________
Cheryl

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

***********************
please mark threads complete if issue is resolved!
AccessMSSQL is offline   Reply With Quote
Old 10-26-2012, 12:23 PM   #34
jcruzAME
Newly Registered User
 
Join Date: Oct 2011
Posts: 135
Thanks: 1
Thanked 0 Times in 0 Posts
jcruzAME is on a distinguished road
Re: Question About Some Code

Changed the format and added providerName, still get the error.
jcruzAME is offline   Reply With Quote
Old 10-26-2012, 12:26 PM   #35
jcruzAME
Newly Registered User
 
Join Date: Oct 2011
Posts: 135
Thanks: 1
Thanked 0 Times in 0 Posts
jcruzAME is on a distinguished road
Re: Question About Some Code

Not sure if this will help but here is a link to the error page I receive.

http://i.imgur.com/fXsp9.png
jcruzAME is offline   Reply With Quote
Old 10-26-2012, 12:32 PM   #36
AccessMSSQL
Seasoned Programmer-ette
 
Join Date: May 2012
Location: Los Angeles, California
Posts: 636
Thanks: 1
Thanked 111 Times in 109 Posts
AccessMSSQL will become famous soon enough AccessMSSQL will become famous soon enough
Re: Question About Some Code

Are you sure named pipes is set up properly on SQL Server. Here's a screenshot that shows if it is or not. Not sure if you are verifying this stuff yourself or if your Server guy is just telling you it is?? You need to go to SQL Server Configuration Manager to set this up.
Attached Images
File Type: jpg SQLServerConfigurationManager.jpg (35.2 KB, 103 views)
__________________
Cheryl

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

***********************
please mark threads complete if issue is resolved!
AccessMSSQL is offline   Reply With Quote
Old 10-26-2012, 12:32 PM   #37
AccessMSSQL
Seasoned Programmer-ette
 
Join Date: May 2012
Location: Los Angeles, California
Posts: 636
Thanks: 1
Thanked 111 Times in 109 Posts
AccessMSSQL will become famous soon enough AccessMSSQL will become famous soon enough
Re: Question About Some Code

Also, what version of SQL Server are you running? Guess that might help also.

__________________
Cheryl

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

***********************
please mark threads complete if issue is resolved!
AccessMSSQL is offline   Reply With Quote
Old 10-26-2012, 12:33 PM   #38
jcruzAME
Newly Registered User
 
Join Date: Oct 2011
Posts: 135
Thanks: 1
Thanked 0 Times in 0 Posts
jcruzAME is on a distinguished road
Re: Question About Some Code

SQL 2012. I will double check but I'm pretty sure I checked the other day and it was enabled.
jcruzAME is offline   Reply With Quote
Old 10-26-2012, 12:37 PM   #39
AccessMSSQL
Seasoned Programmer-ette
 
Join Date: May 2012
Location: Los Angeles, California
Posts: 636
Thanks: 1
Thanked 111 Times in 109 Posts
AccessMSSQL will become famous soon enough AccessMSSQL will become famous soon enough
Re: Question About Some Code

Oh...okay. Haven't used SQL 2012 yet. Yikes. So not sure what the issue could be. Have you tried just temporarily turning off windows firewall on that macihne and testing again?
__________________
Cheryl

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

***********************
please mark threads complete if issue is resolved!
AccessMSSQL is offline   Reply With Quote
Old 10-26-2012, 12:45 PM   #40
jcruzAME
Newly Registered User
 
Join Date: Oct 2011
Posts: 135
Thanks: 1
Thanked 0 Times in 0 Posts
jcruzAME is on a distinguished road
Re: Question About Some Code

Haven't tried that but I know the network guys have opened the ports necessary for them to communicate.
jcruzAME is offline   Reply With Quote
Old 10-26-2012, 12:48 PM   #41
AccessMSSQL
Seasoned Programmer-ette
 
Join Date: May 2012
Location: Los Angeles, California
Posts: 636
Thanks: 1
Thanked 111 Times in 109 Posts
AccessMSSQL will become famous soon enough AccessMSSQL will become famous soon enough
Re: Question About Some Code

Well, if you finally solve your issue please post the solution. Would love to know what the issue was. Sorry could not be of more help.
__________________
Cheryl

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

***********************
please mark threads complete if issue is resolved!
AccessMSSQL is offline   Reply With Quote
Old 10-29-2012, 10:19 AM   #42
jcruzAME
Newly Registered User
 
Join Date: Oct 2011
Posts: 135
Thanks: 1
Thanked 0 Times in 0 Posts
jcruzAME is on a distinguished road
Re: Question About Some Code

I believe it was a problem with the connection trying to open again and it already being open? I changed the source of the page to a view in the SQL Server and it works, but now my checkboxes that I have on the data grid are disabled. Trying to work that out now.
jcruzAME is offline   Reply With Quote
Old 10-29-2012, 12:07 PM   #43
AccessMSSQL
Seasoned Programmer-ette
 
Join Date: May 2012
Location: Los Angeles, California
Posts: 636
Thanks: 1
Thanked 111 Times in 109 Posts
AccessMSSQL will become famous soon enough AccessMSSQL will become famous soon enough
Re: Question About Some Code

That could be it if you are trying to use the same connection variable. I always dim my connections in the procedure I am running, and then of course close the connection at the end of the procedure. So my procedures would look something like this:

Code:
 Function DoSomeWork(Param1 as string) As boolean
        Dim cmd As New SqlCommand
        Dim conn As New SqlConnection
 
        Try
            OpenSQLConnection(conn)
            cmd = New SqlCommand
            cmd.CommandText = "storedprocedurename"
            cmd.CommandType = Data.CommandType.StoredProcedure
            cmd.Connection = conn
            With cmd
                .Parameters.AddWithValue("@Param1", Param1)
                .ExecuteNonQuery()
            End With
        Catch ex As Exception
            ThrowError("Error in Insert:" & ex.ToString)
        Finally
            CloseConnection(conn)
        End Try
    End Function
and then I store my connection function in another module:
Code:
Public Function OpenSQLConnection(ByRef cn AsSqlConnection) AsBoolean
'Try
If cn IsNothingThen
Try
cn = NewSqlConnection()
Catch ex AsException
ReturnFalse
Exit Function
EndTry
EndIf'Setup Connection Try 
cn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("MyConnection").ConnectionString
cn.Open()
'Catch ex As Exception
' Return False
' Exit Function
'End Try 'Make sure it's open 
If cn.State = Data.ConnectionState.Open Then
ReturnTrue
Else
ReturnFalse
EndIf
EndFunction

Public Sub CloseConnection(ByVal l_conn AsSqlConnection)
If l_conn.State = Data.ConnectionState.Open Then
l_conn.Close()
l_conn.Dispose()
EndIf
l_conn = Nothing
'CloseConnection = True
EndSub

__________________
Cheryl

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

***********************
please mark threads complete if issue is resolved!
AccessMSSQL is offline   Reply With Quote
Reply

Tags
asp.net , connection failed , error 40 , sql server , vb.net

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Code within code.. Newbie Question ezykiwi Modules & VBA 4 10-05-2006 07:06 AM
Code Question ppoole16 Forms 1 08-22-2003 07:56 AM
Code Question JustMaybe General 3 12-10-2002 04:49 AM
Code question Peter Paul Modules & VBA 1 04-25-2001 12:12 AM
Code Question Peter Paul Modules & VBA 1 05-23-2000 02:28 AM




All times are GMT -8. The time now is 08:57 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World