G_Waddell 131 Posting Whiz in Training

Hi,
The combobox will take objects rather than just strings as it's items.

I tend to make a custom class I call it dataitem and give it a string property and a data property. You then can override the ToString to return your String value:

Class DataItem

Private _Data as object
Private _Text as string

Public Property Data as object
Get()
    Return _Data
End Get
Set (byVal value as object)
    _Data = value
End Set
End Property

Public Property Text
Get()
    Return _Text
End Get
Set (byVal value as string)
    _Text = value
End Set
End Property

Public Overrides Function ToString() As String
    Return _Text
End Function

Sub New (Optional byVal Data as Object = nothing, Optional ByVal Text as String ="")
    _Text = Text
    _Data = Data
End Sub

End Class

Now you can add your combobox items like this:

MyComboxbox.items.add( new DataItem(1,"Male"))
MyComboxbox.items.add( new DataItem(2, "Female"))

Then when you want to read the value:

dim DI as DataItem
dim MySex as integer
DI = MyCombobox.SelectedItem

MySex = cint(DI.Data)
G_Waddell 131 Posting Whiz in Training

Hi,

OK so you have a class set up for your stock and you are using it correctly, from the looks of what you have given. How will you show the user the board?

G_Waddell 131 Posting Whiz in Training

Hi,
As the good reverend says drag and drop - make sure you are in the design view of the form - unless are you using something other than WinForms?

G_Waddell 131 Posting Whiz in Training

Hi Like the other guys here are saying, try learning a new language or technology. New things are coming out all the time - how about seeing if you can do one of the games you did in VB.Net but in C# or Java

G_Waddell 131 Posting Whiz in Training

Hi,

Your going to have to loop through all the subfolders from your starting point all the way down to where you can not find any sub folders trouble is your going to have to keep doing this for each folder you find and each of it's sub folders...

If you want to be able to give your users the option of selecting a folder why not use the FolderBrowserDialog and let them navigate?

G_Waddell 131 Posting Whiz in Training

Hi,
If I understand you, you want to add new records (and changes?) in your dataset to the database?

Did you use a DataAdapter to fill the DataSet? IF so you need to specify its UPDATE Commands:

Public Function CreateCommandAndUpdate( _
    ByVal connectionString As String, _
    ByVal queryString As String) As DataSet

    Dim dataSet As DataSet = New DataSet

    Using connection As New OleDbConnection(connectionString)
        connection.Open()
        Dim adapter As New OleDbDataAdapter()

        adapter.SelectCommand = New OleDbCommand( _
            queryString, connection)

        Dim builder As OleDbCommandBuilder = _
            New OleDbCommandBuilder(adapter)

        adapter.Fill(dataSet)

        ' Code to modify the data in the DataSet here.  

        ' Without the OleDbCommandBuilder this line would fail.
        builder.GetUpdateCommand()
        adapter.Update(dataSet)
    End Using 
    Return dataSet
End Function
G_Waddell 131 Posting Whiz in Training

Hi
Are these tables on different databases? If not you could look at using a UNION in your Select statement to give all the results in one query.

OR you can create a new blank Datatable that is a clone of one of the existing tables and populate with each of your twenty six results to get a single datatable.

G_Waddell 131 Posting Whiz in Training

Hi Not sure what you are looking for, Your code will give you something like:

<ServerName>
<ServerName>\<Instance1Name>
....
<ServerName>\<InstanceNName>

if you are allowing users to configure a database connection have you tried using the DataConnectionDialog class? It will handle all that interface for you and return the necessary connection string.

G_Waddell 131 Posting Whiz in Training

Hi
Probably it is something like that but why so many blanks? The only thing I can think of is documents that were created during earlier debugging attempts

G_Waddell 131 Posting Whiz in Training

Hi,
Does your XML file only contain one entry for the Launcher? and the Launcher can only have one application and name entry?

Also in your code you have GetVerLink = _reader.Value.Trim() on your Version entity but I don't see a value entry just a name attribute.

G_Waddell 131 Posting Whiz in Training

Hi
What is "WaitForLoginBrowser" and where is it stored in your application? I take it is some sort of sub routine. Is it available to your form on load?

G_Waddell 131 Posting Whiz in Training

Hi,

I think I did solve it although it's kind of a cheat, I put my loop where I close the documents down after I populate the bookmarks and it appears to work. It still does not explain the multiple documents opening though!

G_Waddell 131 Posting Whiz in Training

Hi,

Getting some strange behaviour when using Interop to create a Word document from a template. I'm using word to generate a nicely formatted and printable Receipt from Sage 200 based on a Word Template. The code should open Word then create a new document based on the template I have created with bookmarks to populate with the receipt data.

The issue is that instead of seeing a single document, I see about 5-6 documents appearing! One of the documents is based on the template I want and the rest are all blank. Also, the document based on the template is sometimes the Active document but sometime it isn't. I only want the single document to be visible. Anyone out there any ideas?

Here is my code:

Sub ShowReceipt (byRef TemplatePath as string)

dim objWord, objDoc as object

'Late bind to avoid version issues
objWord = CreateObject("Word.Application")
With objWord
    .Visible = True
End With

objDoc = objWord.Documents.Add(Template:=TemplatePath)
With objDoc
    .Bookmarks("CustomerNAME").Range.Text = Trim(Customer.Name)
    .Bookmarks("CustomerADDRESS").Range.Text = CustomerAddress
    .Bookmarks("CustomerCONTACT").Range.Text =  CustomerContactName
    .Bookmarks("AMOUNT").Range.Text = ChequeValue
    .Bookmarks("RECEIPTDATE").Range.Text = FormatDateTime(ReceiptDate, DateFormat.LongDate)
    .Bookmarks("CURRENTBALANCE").Range.Text = Format(NewBalance, "#.00")
End With
End Sub

I did try adding the following code after adding the objDoc:

for each Item as Object in objWord.Documents
    if Not Item.Equals(objDoc) then
        Item.Close(SaveChanges:=False)
    End if
next

and while stepping through in debug mode, I could see documents being closed and the objDoc being "skipped" but there were still other documents open at the end of the routine.

G_Waddell 131 Posting Whiz in Training

Hi
You should look up the OLEDBConnection Class to find out how to run SQL against a Database through OLEDB (as opposed to SQL Server).

To connect to the Access database through the OLEDBConnection Class, you will need a connection string to connect to Access

This should get you started - there are loads of examples of code both in MSDN and other VB.NET sites as well as examples and snippits on this very forum.

G_Waddell 131 Posting Whiz in Training

Ok,
I have it now, using an example from elsewhere - I wasn't taking the namespace into account.

Dim ns As XNamespace = "urn:iso:std:iso:20022:tech:xsd:pain.002.001.03" 'The xml namespace
Dim FileErrs = doc.Descendants(ns + "OrgnlPmtInfAndSts").Elements(ns + "TxInfAndSts")
For each FileErr in FileErrs
     '/OrgnlTxRef/Amt/InstdAmt
     dblAmount = FileErr.Element(ns + "OrgnlTxRef").Element(ns + "Amt").Element(ns + "InstdAmt").Value
     '/OrgnlTxRef/MndtRltdInf/MndtId
     strMandateReference = FileErr.Element(ns + "OrgnlTxRef").Element(ns + "MndtRltdInf").Element(ns + "MndtId").Value
     '/OrgnlTxRef/MndtRltdInf/DtOfSgntr
     dtDateMandateSigned = FileErr.Element(ns + "OrgnlTxRef").Element(ns + "MndtRltdInf").Element(ns + "DtOfSgntr").Value
     strCustomerBIC = FileErr.Element(ns + "OrgnlTxRef").Element(ns + "DbtrAgt").Element(ns + "FinInstnId").Element(ns + "BIC").Value
     strCustomerIBAN = FileErr.Element(ns + "OrgnlTxRef").Element(ns + "DbtrAcct").Element(ns + "Id").Element(ns + "IBAN").Value
     strCustomerAccountName = FileErr.Element(ns + "OrgnlTxRef").Element(ns + "Dbtr").Element(ns + "Nm").Value
     strTransactionType = FileErr.Element(ns + "OrgnlTxRef").Element(ns + "PmtTpInf").Element(ns + "SeqTp").Value
     strEndToEndID = FileErr.Element(ns + "OrgnlEndToEndId").Value
     strReasonCode = FileErr.Element(ns + "StsRsnInf").Element(ns + "Rsn").Element(ns + "Cd").Value
     strReason = _ErrorCodes.Item(strReasonCode).Trim
     DT.Rows.Add(dblAmount, strMandateReference, dtDateMandateSigned, strCustomerBIC, strCustomerIBAN, strCustomerAccountName, strTransactionType, strEndToEndID, strReasonCode, strReason)
Next
G_Waddell 131 Posting Whiz in Training

Hi tinstaff,

I tried that but no luck..
I tried just to get just the CstmrPmtStsRpt children out as a test:
Dim FileErrs = From Document In doc.Descendants From CstmrPmtStsRpt In Document.Elements("CstmrPmtStsRpt") Select CstmrPmtStsRpt.Elements
But I still get enumeration yielded no results

G_Waddell 131 Posting Whiz in Training

Thanks tinstaaf,

In the words of the great philosopher Homer - DOH! I will now go and repeatedly bang my head off my desk.

G_Waddell 131 Posting Whiz in Training

Visual Studio Express Editions are free to use. With regards to differences between the free editions and paid for ones, I have a paid for copy of Visual Studio 2008 and I can build windows apps, web apps the whole shooting match. I've just downloaded Visual Studio 2012 Express for Desktop on to a VM I have for a play around with and this version is limited to desktop apps (clues in the name I suppose!) as far as production goes I can't see any difference. I think it is just that you need separate Express editions for what you are developing.

G_Waddell 131 Posting Whiz in Training

Hi All,

I'm fairly new to using Linq but I thought I had a handle on it, apparently not though. I'm processing an XML file sent out as an error report by a third party. I have no control over this file and it has been developed to an industry standard so I can not get the format changed even if I want to.

Anyway here is a "cut down" sample of the file, sorry about the size but I've only put things I need to query on.:

<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.002.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <CstmrPmtStsRpt>
        <GrpHdr>
            <!-- I dont use this area so I wont type the elements here-->
        </GrpHdr>
        <OrgnlGrpInfAndSts>
            <OrgnlMsgId>MCY20131</OrgnlMsgId>
            <OrgnlMsgNmId>pain.008.001.02</OrgnlMsgNmId>
            <OrgnlNbOfTxs>10</OrgnlNbOfTxs>
            <OrgnlCtrlSum>6600.00</OrgnlCtrlSum>
            <StsRsnInf>
                <Rsn>
                    <!-- If this path exists and there is a value in Cd then the whole file was rejected.-->
                    <Cd>MD03</Cd>
                </Rsn>
            </StsRsnInf>
        </OrgnlGrpInfAndSts>
        <OrgnlPmtInfAndSts>
            <!-- There could be multiple TxInfAndSts depending on number of transactions imported -->
            <TxInfAndSts>
                <!-- Need the OrgnlEndToEndId value to link back to Import Record-->
                <OrgnlEndToEndId>20131</OrgnlEndToEndId>
                <StsRsnInf>
                    <Rsn>
                        <!-- Reason for rejection of transaction-->
                        <Cd>AC01</Cd>
                    </Rsn>
                </StsRsnInf>
                <OrgnlTxRef>
                    <Amt>
                        <InstdAmt Ccy="EUR">660.00</InstdAmt>
                    </Amt>
                    <PmtTpInf>
                        <SeqTp>FRST</SeqTp>
                    </PmtTpInf>
                    <MndtRltdInf>
                        <MndtId>0008Customer 801012013</MndtId>
                        <DtOfSgntr>2013-01-01</DtOfSgntr>
                    </MndtRltdInf>
                    <Dbtr>
                        <Nm>Customer 8</Nm>
                    </Dbtr>
                    <DbtrAcct>
                        <Id>
                            <IBAN>IE20BOFI90003333817105</IBAN>
                        </Id>
                    </DbtrAcct>
                    <DbtrAgt>
                        <FinInstnId>
                            <BIC>BOFIIE20</BIC>
                        </FinInstnId>
                    </DbtrAgt>
                </OrgnlTxRef>
            </TxInfAndSts>
        </OrgnlPmtInfAndSts>
    </CstmrPmtStsRpt>
</Document>

So I've written a sub that takes in the filepath to the XMl file and then produces either an overall error code or populates a datatable for each transaction error that I place in a grid.

First …

G_Waddell 131 Posting Whiz in Training

Hi,

Try modifying the SQL statement from Select Dept From SoldItems Where SalesDate >= @StartDate And SalesDate <= @EndDate to Select Distinct Dept From SoldItems Where SalesDate >= @StartDate And SalesDate <= @EndDate

The DISTINCT command does precisely that i.e. returns only DISTINCT results.

G_Waddell 131 Posting Whiz in Training

Hi you may want to look up Interop - it will enable you to open a new word application, create a word document and write to it.

A word on Interop:

  • It will only work if a version of word is installed on the clients machine.
  • You may want to use late binding unless you know for sure which version of Word is present on every client machine. e.g. an office environment where everyone has Office 2013 installed
G_Waddell 131 Posting Whiz in Training

Hi,
I still occasionally have to maintain some classic ASP 3.0 sites I made the leap from ASP to ASP.Net in the early 2000's I've also done at bit of PHP as well I found it easier to learn VB.NET and go to making ASP.Net Pages with a VB.NET backend - I was also doing windows development at the time in my job so I started developing Apps with VB.Net too, once you are comfortable with VB.NET and ASP.NET then you can go on and learn C# and use that to make ASP.NET pages too. You should never limit yourself to one language or technology as you will be more appealing in the job market. You could also try php as well later on. I just think you'd probably make the jump to VB.NET with ASP.NET quicker due to you ASP (VBScript) background.

G_Waddell 131 Posting Whiz in Training

Hi,
Do your code behind functions fire on postback?

G_Waddell 131 Posting Whiz in Training

What does the error say? BTW your code looks odd to me not VB.Net

G_Waddell 131 Posting Whiz in Training

Hi,
You can use the dropdown on the properties window to select any controls or forms, even ones you can not see on the screen (simply scroll to the one you want,) upon being selected it will become active and you can cut and paste etc.

G_Waddell 131 Posting Whiz in Training

Hi,
Sorry not 100% sure what you mean. Maybe some of the code you've written so far would help?

G_Waddell 131 Posting Whiz in Training

Hi Try:

while objDataReader.read()
    cmbExecutor.selecteditem.value = objDataReader.GetInt32(0)
End While

Which will force it to supply the first integer value in the row

One Question though as you loop through the data rows returned by the data reader, you will be constantly changing the selected value of cmbExecutor, is this what you want to do? and if a value is returned from the database that has no match in the combobox items you will get an error

G_Waddell 131 Posting Whiz in Training

I know this is from the C# forum but it maybe worth having a read of...
What Resources are available to you

G_Waddell 131 Posting Whiz in Training

Hi,
I'm a bit rusty at this but here goes, in your code the buttons are being dynamically created based on the database records so you have to specify which sub routine to run on each button that takes the command arguments and uses them. i.e. you can not rely on a imgbtnApprove_onclick automatically handling the imgbtnApprove click event because there are multiple imgbtnApprove's created on the fly by the results of your query. You must specify in the buttons OnCommand property to use the "imgbtnApprove_onclick" sub routine. Then in the Sub routine you can use your Command argument property to identify what is being approved:

<asp:ImageButton ID="imgbtnApprove" CommandArgument='<%#EVAL("SO_No")%>' OnCommand="imgbtnApprove_OnClick" />
.....

Sub imgbtnApprove_OnClick(byval Sender as object, ByVal e as CommandEventArgs)
Dim SO_NO as integer = e.CommandArgument
'do what ever....
End Sub

Also, if you use the CommandName property you could have one routine handle all the approve reject and email buttons:

Sub imgBtn_OnClick(byval sender as object, byval e as CommandEventArgs)
dim Action as String = e.CommandName
dim So_No as integer = e.CommandArgument
Select Action
    case "Approve"
        'approve the record
    case "Reject"
        'Reject the record
    Case Else
        'Email?
End Select
End Sub
G_Waddell 131 Posting Whiz in Training

<M/>

he only posted once and hasn't returned...

Could that be because he is a newbie and the reaction to their first post (probably sent as an intro,) was basically F off and stop spamming?

G_Waddell 131 Posting Whiz in Training

Look at your code on setplayerturn:

Sub setplayerturn()
    If isFirstPlayerTurn = True Then
        isFirstPlayerTurn = False
        isSecondPlayerTurn = False
        txtfirstplayer.BackColor = Color.LightGreen
        txtsecondplayer.BackColor = Color.White
    ElseIf isSecondPlayerTurn = True Then
        isSecondPlayerTurn = False
        isFirstPlayerTurn = False
        txtsecondplayer.BackColor = Color.LightGreen
        txtfirstplayer.BackColor = Color.White
    End If
End Sub

If IsFirstPlayerTurn is True then you set isFirstPlayerTurn to False AND isSecondPlayerTurn to False If isFirstPlayerTurn is False you set isSecondPlayerTurn to False AND isFirstPlayerTurn to False so either way it will never be any players turn.

G_Waddell 131 Posting Whiz in Training

Hi
You can move objects around in VB.net using bottom, top, left, right properties for example a Button Control.

You will however need to use a DO events as well.

G_Waddell 131 Posting Whiz in Training

Hi,

Sorry but you will have to read in every line of the text in order to identify where the text you are looking for begins and ends and begins again if you see what I mean. You will only want to retain the sections of text you need. Why don't you post up what code you have done so far? Here is a simple example I have used in the past to identify tags in HTML:

sub Count_Tags( byref InputHTML as String)
dim ACount, BCount, ICount PCount as integer
dim i as integer
dim sChar as string
dim bInTag as Boolean 
dim sTag as string
for i =1 to len(InputHTML)
    sChar = mid(InputHTML,i,1)
    if bInTag then
        sTag &= lcase(sChar)
        if sChar =">" then
            if instr(sTag,"<a") <> 0 then
                ACount +=1
            elseif instr(sTag, <"b") <> 0 ANDALSO instr(sTag,"<br") =0 then
                BCount +=1
            elseIf instr(sTag,"<i") <> 0 ANDALSO instr(sTag, "<iframe") = 0 then
                ICount +=1
            elseif instr(stag, "<p") <> 0 then
                PCount +=1
            end if
            bInTag = false      
        end if
    elseif sChar ="<" then
        bInTag = true
        sTag="<"
    end if
next
Msgbox("There were " &PCount &" paragraphs, " &ACount &" web links, " &BCount &" instances of Bold text, " &ICount &" instances of Italic text.")
G_Waddell 131 Posting Whiz in Training

Hi,

The OLEDB connection to Access is not as sophisticated as the SQLDB to SQL server, basically it doesn't support named parameters so you must pass each parameter in in order. i.e. taking your query: SELECT [Customer Number], [Last Name], [First Name], Address, City, State, [ZIP Code], [Telephone Number], [Account Balance], [Date Last Payment] FROM CustomerAccounts WHERE ([Last Name] LIKE ?) OR ([Customer Number] LIKE ?)

You have to pass in two parameters in the order value to search against Last Name, value to search against Customer Number. So if you only want to search against one, the other must be blank.
With a SQL connection you can do this:

     dim cmd as SQLCommand
    ' establish connection string blah blah blah
    Cmd.text = "SELECT [Customer Number], [Last Name], [First Name], Address, City, State, [ZIP Code], [Telephone Number], [Account Balance], [Date Last Payment] " & _
     "FROM CustomerAccounts WHERE ([Last Name] LIKE @LastName ) OR ([Customer Number] LIKE @CustNumber)"
    cmd.Parmeters.add("@CustNumber", "123%')
    cmd.Parameters.add("@LastName", "Smith")
    'Just use a datareader for example
    MyDatareader =cmd.ExecuteReader()

Because we can specify parameter names with the SQL query we can put them in any order and we know the correct parameter is populated. FindAccountDataSet.CustomerAccounts with the SQL server connection is behaving as if it was passing in a blank string for whatever parameter is not specified.

Now with OLEDB to the Access it has to have both a parameter for Last Name and Customer Number passed in. Look at the Query you have to …

G_Waddell 131 Posting Whiz in Training

Hi,
I'll assume that you do realise that the </a> tag is the end tag for <a> and not <img>
Also are you sure the attributes inside the tag are using single quotes rather than double quotes?
<img class="stat_icon" src="/images/red.png"> is different from "<img class='stat_icon' src='/images/red.png'>.
Why not use Instr to get the start and end positions of the data then mid to get the actual data:

 Dim sourcecodee As String = sr.ReadToEnd()
 dim iStart, iEnd as integer
 dim datamatch as string
 'rather than worry about the quotes I'll grab the class name
 iStart = Instr(lcase(sourcecodee), "stat_icon")
 If iStart <> 0 andalso instr(iStart, sourcecodee, ">") <> 0 then
    'go to end of the img tag...
    iStart = instr(istart, sourcecodee,">")
    'get first "</a>" after start
    iEnd = instr(istart,lcase(sourcecodee),"</a>") 
    If iEnd <> 0 then
        datamatch = mid(sourcecodee, iStart , iEnd - iStart)
    end if
end if
G_Waddell 131 Posting Whiz in Training

I'm luckly I live in Ireland - there are so much activities available for kids to do in the local community for free on next to nothing. For example my son's weekly activities break down as follows Monday & Wednesday nights 1 hour class BJJ (Brazilian Jujistu) €5 per class (€10 for the week), Thursday night 1 hour Judo €5, Friday Night 1 hour hurling training free, Saturday morning 1 hour football (or soccer for you barbarians,) free, 2 hours Theatre studies €15 and 1 hour Judo €5. He could have also done Gaelic Football for an hour for free but it clashes with his Theatre studies.

Despite all this at his recent health check the health nurse expressed concerns over him being in the upper 2% for body weight at his age! - I pointed out she had just said he was also in the upper 10% for height for his age, he carried out all these activites and had a six pack and defined muscles at age 6!

matthewwhite011 commented: What you are doing seems to be according to the ideal cases. However, nobody can do such a hard work i bet. +0
G_Waddell 131 Posting Whiz in Training

Sorry, if you want to use the override a behaviour of the base class on your custom class you would do it like this:

Public class DataItem

private _Data as Object
private _Display as string

Public Property Data As Object
     Get()
        return _Data
    end Get 
    Set (byref value as Object)
        _Data = Value
    end Set
End Property
Public Property Display as String
    Get() 
        return _Display
    end Get
    Set (byref value as Object)
    _Display = value
    end Set
End Property
Public Overrides Function ToString()
    Return _Display
End Function
Public Sub New (Optional ByVal Key as String ="", Optional ByVal Item as Object = nothing)
    _Data = Item
    _Display = Key
End Sub
End Class
G_Waddell 131 Posting Whiz in Training

I was going to say you could use the AddHandler Statement BUT if you follow the example given by tinstaafi you don't need to - the custom class is always set to read only and always has a white background.

I'll give you an example of using addhandler on a control if you want, but you could also just append Handles Event to the sub.

'Example of setting a sub routine to handle an event with addhandler:

sub HandleMyEvent1(byval sender as object, byval e as system.eventArgs)
    msgbox("You clicked me")
end sub

dim mycustomControl as new CustomControl 

me.controls.add(mycustomControl)

addhandler mycustomControl.OnClick, AddressOf HandleMyEvent1

'Example of setting sub routine with handles
dim MyControl2 as New CustomControl
me.controls.add(MyControl2)

sub HandleMyEvent2(byval sender as object, byval e as system.eventArgs) Handles MyControl2.MouseOver
    msgbox ("Mouse Over me")
End Sub
G_Waddell 131 Posting Whiz in Training

Hi,

Looking at you code, if the form shows as a dialog then your interface and form that calls the code are working... The code inside your form, handles a keypress on txtbox1 inside the form. So when someone enters text into the form does it handle it - what happens? Have you tried putting a msgbox inside the form code to see if it is firing?

G_Waddell 131 Posting Whiz in Training

Hi,

I'd question that then because ExecuteNonQuery is actually a valid method on the command object as is ExecuteScalar. The one I'd have questions about is ExecuteQuery. I've never used it or seen it being used and the only time I've heard it mentioned is as a catch all term for ExecuteReader, ExecuteXMLReader etc.

G_Waddell 131 Posting Whiz in Training

Hi,

The fact he sent you an updated exe to accomplish this suggests he did hard code it somewhere.

G_Waddell 131 Posting Whiz in Training
  1. Dim newPage As New TabPage() should be Dim newPage As TabPage - NOTE: there is no () at the end of the line. (If you put a () you are declaring it to be an array of this type)

  2. You did not specify or open the connection to the database for the command to use:

  3. Yes, this is fine

To Connect to your database you must use a connection string, you must then let your command know that it has to use this connection and then open the connection to allow the command to use it. Bookmark the following link in your browser connectionstrings.com this site lists just about ever connection string format you'll ever need.

Here is an example for access: dim conn as new oledbconnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=pathtomyaccessDB;Persist Security Info=False")

Now you will need to open the connection : conn.open

Next where you set up your command add the following line :cmd.Connection = conn

Now when your command fills the dataset, the command will connect to the Access database

G_Waddell 131 Posting Whiz in Training

No worries

G_Waddell 131 Posting Whiz in Training

Hi,

It is not a type it is a formula in a crystal! e.g. I have a table that has a column "cost", it has 3 rows with cost values of 1, 1, 2 I want my crystal field, TOTCosts, to display the sum of the cost field:=SUM(Costs) my Crystal Field now displays 4 (=1+1+2)

G_Waddell 131 Posting Whiz in Training

ExecuteNonQuery..
1.It will not return any data.
2.It is used with insert and update.
3.It returns only the number of rows affected.

ExecuteScaler..
1.It returns only one value.
2.That value will the first column first row value.

ExecuteReader, ExecuteXMLReader etc.(usually referred to as Execute Query)
1.Its for command objects.
2.It returns the values given by database through select statement.

Did the questionon the quiz want you to get records or a value out of the Database? If so, that is why ExecuteNonQuery is not a valid answer.

G_Waddell 131 Posting Whiz in Training

Hi,

It'd be easier to figure out if we can see some of your code - where you make the calls etc between the projects.

G_Waddell 131 Posting Whiz in Training

Hi,

It is refering to a formula : a = SUM(MyField1)

G_Waddell 131 Posting Whiz in Training

Hi,
I'm not sure exactly what your question is but this link will give you all the information on the SQL Command Object. The OLEDB Command object would have a similar syntax.

G_Waddell 131 Posting Whiz in Training

Hi,

You will need to output the new Order Number as an output parameter or return in your Stored Procedure. You should drop the datareader too and use cmd.ExecuteNonQuery as you are not returning a data result set.

Tweek your stored procedure something like as follows:

CREATE PROCEDURE Update_OrderNo @OrdNo BIGINT OUTPUT

INSERT INTO ORDRNUMBERREC(OrderNo,UserId,CreateDate)
SELECT MAX(OrderNo)+1,'system',GETDATE() FROM ORDRNUMBERRECWITH (TABLOCKX)

--CHECK IT HAS INSERTED CORRECTLY
IF @@ERROR =0 
BEGIN
    SELECT @OrdNo = MAX(OrderNo) FROM ORDRNUMBERRECWITH 
END
--IN Case of Failure
IF @@ERROR <> 0 
BEGIN 
    -- Log the error - use a better message than I did :)
    RAISERROR('Awhhh Crap',16,1) WITH LOG   
    SELECT @OrdNo = 0
END

Now for you VB Code:

cmd = New SqlCommand
cmd.CommandText = "Update_OrderNo"
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = con
'Add your parameter
cmd.Parameters.Add("@OrdNo", SqlDBType.BigInt)
'specify it is an output parameter
cmd.Parameters("@OrdNo").Direction = ParameterDirection.Output
'open connection if necessary
If con.State.ToString <> "Open" then
    con.open
end if
'Run procedure
cmd.ExecuteNonQuery
'Get Result
ordrno = cmd.Paramters("@OrdNo").value

Hope this helps

G_Waddell 131 Posting Whiz in Training

Hi,
the "p" at the end was to allow him to refer to the Personel table as p instead of writing out Personel all the time i.e. p.PersonelID instead of Personel.PersonelID. Try generating the query inside your Access using the QBE, make sure your happy with the results then switch over to the SQL designer view and you will get the correctly formatted SQL for Access.