Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Newbie Connection problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Johnson - 25 Jul 2006 16:33 GMT
I have spent 3 plus hours looking at documentation and references.  I
have copied code and changed variables... but still nothing.  Here is
my connection string and scalar.

       Dim sqlConn As New SqlConnection("Data Source=*Server;Initial
Catalog=*DBName;Integrated Security=SSPI;")
       Dim sqlComm As New SqlCommand(strSQL, sqlConn)
       sqlConn.Open()
       Dim strUserID As Integer = sqlComm.ExecuteScalar()
       sqlConn.Close()
       MsgBox(strUserID)

The SQL statement is correct and runs perfectly in the query analyzer.
It returns a 1 in SQL Server which is the correct result.  However it
returns a 0 whenever I try to access this data in my .NET windows app.
Am I forgetting anything?

-Lost on what to do next
Larry Lard - 25 Jul 2006 17:05 GMT
> I have spent 3 plus hours looking at documentation and references.  I
> have copied code and changed variables... but still nothing.  Here is
[quoted text clipped - 12 lines]
> returns a 0 whenever I try to access this data in my .NET windows app.
> Am I forgetting anything?

What's the command?

Also, turn Option Strict On (this should be your default mode of
operation), and supply the necessary conversion functions. You may
discover something. (I know you're not running with Option Strict On,
because SqlCommand.ExecuteScalar returns an Object, which needs an
explicit conversion to get put into an Integer)

Signature

Larry Lard
larrylard@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version

Johnson - 25 Jul 2006 18:22 GMT
Found out that my SQL server is not being recognized as a connection
when the provider is Microsoft SQL Server.  It is only being recognized
when I use the Microsoft ODBC Driver as the provider?  I turned on
Option Strict and changed the integer to an object.  I also changed the
connection and command to ODBC... it still isn't working though.  I
think I might have to figure out how to get my SQL server recognized as
a SQL provider.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.