Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,542 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,863 people online right now. Registration is fast and FREE... Join Now!




VB express 2005 connect to SQL2005 server

 
Reply to this topicStart new topic

VB express 2005 connect to SQL2005 server, Select from table to receive fax numbers

tgallina
15 Aug, 2008 - 07:18 AM
Post #1

New D.I.C Head
*

Joined: 15 Aug, 2008
Posts: 2

I have a general VB fax program working fine, however now I would like to connect to a SQL database and get the fax numbers to send out to our customers. What code is missing to connect to the SQL server? I'm leaving the test fax - individual file just for testing purposes. Please don't respond with links, moreover I can do my own google searches!



CODE

Public Class frm1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntransmitt.Click
        Dim objFaxDocument As New FAXCOMEXLib.FaxDocument
        Dim objFaxServer As New FAXCOMEXLib.FaxServer
        Dim objSender As FAXCOMEXLib.FaxSender
        Dim JobID As Object
        Dim devices As FAXCOMEXLib.FaxDevice



        Dim ds As DataSet
        Dim NurseryConnection As SqlClient.SqlConnection
        Dim OpenCustomer As SqlClient.SqlCommand


        [b]'Connect to SQL DB
        NurseryConnection = New SqlClient.SqlConnection("server=(server3500\NuserySQL);database=DevNursery Trusted_Connection=yes")[/b]


        
        'open customer table




        'Connect to the fax server
        objFaxServer.Connect("serverfax")
        objFaxDocument.Body = "C:\test.txt"


        'Add the recipient with the fax number xxxxxxxx
        objFaxDocument.Recipients.Add("1111111", "Todd")



        'Submit the document to the connected fax server

        'and get back the job ID.
        JobID = objFaxDocument.ConnectedSubmit(objFaxServer)

        MsgBox("The Job ID is :" & JobID(0))



        'Set the cover page type and the path to the cover page
        objFaxDocument.CoverPageType = FAXCOMEXLib.FAX_COVERPAGE_TYPE_ENUM.fcptSERVER


        'objFaxDocument.CoverPageType.FAXCOMEXLib.FAX_COVERPAGE_TYPE_ENUM.fcptNONE()
        objFaxDocument.CoverPage = "generic"


        'Provide the cover page note
        objFaxDocument.Note = "Availability Sheet "


        'Provide the address for the fax receipt
        objFaxDocument.ReceiptAddress = ""

        'Set the receipt type to email

        objFaxDocument.ReceiptType = FAXCOMEXLib.FAX_RECEIPT_TYPE_ENUM.frtMAIL


        'Set the receipt type to email
        objFaxDocument.ReceiptType = FAXCOMEXLib.FAX_RECEIPT_TYPE_ENUM.frtMSGBOX





        Exit Sub

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclose.Click
        Close()
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub frm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

User is offlineProfile CardPM
+Quote Post

dineeshd
RE: VB Express 2005 Connect To SQL2005 Server
15 Aug, 2008 - 08:19 AM
Post #2

D.I.C Addict
Group Icon

Joined: 30 Jun, 2008
Posts: 578



Thanked: 16 times
Dream Kudos: 575
My Contributions
Make sure your connection string is right. Refer this link for some help -- SQL Server 2005 Connection String

And please use Code Tags while posting code
Example: code.gif
User is offlineProfile CardPM
+Quote Post

Jayman
RE: VB Express 2005 Connect To SQL2005 Server
15 Aug, 2008 - 09:21 AM
Post #3

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,947



Thanked: 42 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
Moved to VB.NET.
User is offlineProfile CardPM
+Quote Post

jens
RE: VB Express 2005 Connect To SQL2005 Server
17 Aug, 2008 - 11:01 AM
Post #4

D.I.C Head
Group Icon

Joined: 9 May, 2008
Posts: 113



Thanked: 3 times
Dream Kudos: 150
My Contributions
QUOTE

NurseryConnection = New sqlClient.SqlConnection("server=(server3500\NuserySQL);database=DevNursery Trusted_Connection=yes")[/b]


I'd do it like:
CODE

  "Data Source = server3500\NuserySQL; Initial Catalog = DevNursery; integrated security=true"


Think that would work.

/Jens
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 10:45PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month