Click here to Skip to main content
15,913,055 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionNeed help designing label and envelope prinitng in vb Pin
rajnee19-Sep-07 20:53
rajnee19-Sep-07 20:53 
AnswerRe: Need help designing label and envelope prinitng in vb Pin
DanB198319-Sep-07 22:02
DanB198319-Sep-07 22:02 
QuestionDAll And BLL Template Question Pin
Vimalsoft(Pty) Ltd19-Sep-07 20:08
professionalVimalsoft(Pty) Ltd19-Sep-07 20:08 
AnswerRe: DAll And BLL Template Question Pin
Colin Angus Mackay20-Sep-07 0:10
Colin Angus Mackay20-Sep-07 0:10 
GeneralRe: DAll And BLL Template Question Pin
Vimalsoft(Pty) Ltd20-Sep-07 1:49
professionalVimalsoft(Pty) Ltd20-Sep-07 1:49 
GeneralRe: DAll And BLL Template Question Pin
Colin Angus Mackay20-Sep-07 2:33
Colin Angus Mackay20-Sep-07 2:33 
GeneralRe: DAll And BLL Template Question Pin
Vimalsoft(Pty) Ltd20-Sep-07 2:50
professionalVimalsoft(Pty) Ltd20-Sep-07 2:50 
GeneralRe: DAll And BLL Template Question Pin
Vimalsoft(Pty) Ltd20-Sep-07 3:55
professionalVimalsoft(Pty) Ltd20-Sep-07 3:55 
Hi Colin

i manage to Covert the Code to vb,but in other part will need your Help lets Start here
Public Class Dal

    Dim connectionString As String

    ' <summary>
    'The static initialiser will be called the first time any
    ' method on the class is called. This ensures that the
    ' connection string is available.
    ' </summary>
    Shared Sub Dal()

   DIm   connectionString as String  =  ConfigurationManager.AppSettings["ConnectionString"]
    End Sub


i had a problem with the Connection string

<br />
   DIm   connectionString as String  =  ConfigurationManager.AppSettings["ConnectionString"]<br />

The IDE tells me that "Identifier Expected"

The First one is the namespaces that needs to be imported
<br />
using System.Collections.Generic;<br />

This line it does not recognise the Generic. if i remove it "Generic" it does not Complain.
The Second Function i coverted it like this
Private Function BuildCommand(ByVal storedProcedureName As String)

        ' Create a connection to the database.
        Dim connection = New SqlConnection(connectionString)

        ' Create the command object - The named stored procedure
        ' will be called when needed.
        Dim result As New SqlCommand(storedProcedureName, connection)
        result.CommandType = CommandType.StoredProcedure
        Return result


    End Function

i made it a Function because a sub cannot return a Value.
<br />
<br />

My Following Function is like this
' <summary>
     ' Builds a DataAdapter that can be used for retrieving the
     ' results of queries
     ' </summary>
     ' <param name="storedProcedureName">The name of the stored
     ' procedure</param>
     ' <returns>A data adapter</returns>
     Private Function BuildBasicQuery(ByVal storedProcedureName As String)

         Dim cmd As New SqlCommand(BuildCommand(storedProcedureName))

         'Set up the data adapter to use the command already setup.
         Dim result As New SqlDataAdapter(cmd)

         Return result
     End Function


it never Complained. and the Next one is like this
'<summary>
       ' A sample public method. There are no parameters, it simply
       ' calls a stored procedure that retrieves all the products
       ' </summary>
       ' <returns>A DataTable containing the product data</returns>
       Public Function GetAllProducts()

           Dim DataAdapter As New SqlDataAdapter(BuildBasicQuery("GetAllProducts"))
           'Get the result set from the database and return it
           Dim result As New DataTable
           DataAdapter.Fill(result)
           Return result
       End Function


it never Complained too.

'  <summary>
    ' A sample public method. It takes one parameter which is
    'passed to the database.
    ' </summary>
    ' <param name="invoiceNumber">A number which identifies the
    ' invoice</param>
    ' <returns>A dataset containing the details of the required
    ' invoice</returns>
    Public Function GetInvoice(ByVal invoiceNumber As Integer)

        Dim DataAdapter As New SqlDataAdapter(BuildBasicQuery("GetInvoice"))
        DataAdapter.SelectCommand.Parameters.AddWithValue( _
            "@invoiceNumber", invoiceNumber)

        Dim result As New DataSet
        DataAdapter.Fill(result)
        Return result
    End Function

On this one i need your help, i got Stucked. the Code Complained in the Following line.
<br />
<br />
            Dim DataAdapter As New SqlDataAdapter(BuildBasicQuery("GetInvoice" _<br />
              , "@invoiceNumber", invoiceNumber))<br />


On the Last one, i was Completely lost
Public Function CreateInvoice(ByVal customerId As Integer, _
   ByVal billingAddressId As Integer, ByVal DateTime As Date)

       Dim cmd As New SqlCommand(BuildCommand("CreateInvoice"))
       cmd.Parameters.AddWithValue("@customerId", customerId)
       cmd.Parameters.AddWithValue("@billingAddressId")
           billingAddressId)
       cmd.Parameters.AddWithValue("@date",date)

       cmd.Connection.Open()
       dim result as Integer  = (integer).cmd.ExecuteScalar()
       cmd.Connection.Close()
       Return result
   End Function


The Compiler Complained about All the lines in this Function. the other thing is that i did not understand the Following line in the last function

<br />
            int result = (int)cmd.ExecuteScalar()

i Think i you can confirm my Code, i will try to understand.

Thanks again Colin

Vuyiswa Maseko,

Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding

VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com


GeneralRe: DAll And BLL Template Question Pin
Colin Angus Mackay20-Sep-07 4:23
Colin Angus Mackay20-Sep-07 4:23 
GeneralRe: DAll And BLL Template Question Pin
Vimalsoft(Pty) Ltd20-Sep-07 5:28
professionalVimalsoft(Pty) Ltd20-Sep-07 5:28 
GeneralRe: DAll And BLL Template Question Pin
Dave Kreskowiak20-Sep-07 4:33
mveDave Kreskowiak20-Sep-07 4:33 
GeneralRe: DAll And BLL Template Question Pin
Dave Kreskowiak20-Sep-07 4:48
mveDave Kreskowiak20-Sep-07 4:48 
GeneralRe: DAll And BLL Template Question Pin
Vimalsoft(Pty) Ltd20-Sep-07 5:20
professionalVimalsoft(Pty) Ltd20-Sep-07 5:20 
QuestionRunning two projects as one application Pin
saaaas19-Sep-07 17:52
saaaas19-Sep-07 17:52 
AnswerRe: Running two projects as one application Pin
Christian Graus19-Sep-07 18:19
protectorChristian Graus19-Sep-07 18:19 
QuestionExcel - How to read data from an XML file... Pin
Albert Giraudi19-Sep-07 16:37
Albert Giraudi19-Sep-07 16:37 
AnswerRe: Excel - How to read data from an XML file... Pin
Gary Bigman19-Sep-07 21:16
Gary Bigman19-Sep-07 21:16 
GeneralRe: Excel - How to read data from an XML file... Pin
Albert Giraudi20-Sep-07 16:13
Albert Giraudi20-Sep-07 16:13 
QuestionForm Load Pin
Jodd19-Sep-07 14:04
Jodd19-Sep-07 14:04 
AnswerRe: Form Load Pin
Luc Pattyn19-Sep-07 15:42
sitebuilderLuc Pattyn19-Sep-07 15:42 
GeneralRe: Form Load Pin
Jodd19-Sep-07 22:51
Jodd19-Sep-07 22:51 
AnswerRe: Form Load Pin
helelark12319-Sep-07 20:21
helelark12319-Sep-07 20:21 
AnswerRe: Form Load Pin
Tom Deketelaere19-Sep-07 20:43
professionalTom Deketelaere19-Sep-07 20:43 
GeneralRe: Form Load Pin
Jodd19-Sep-07 22:52
Jodd19-Sep-07 22:52 
QuestionVB 6 and VB.net 2003 Network objects Pin
Phill_Goin19-Sep-07 12:27
Phill_Goin19-Sep-07 12:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.