Click here to Skip to main content
13,259,771 members (47,877 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i want to write a code for an insert query
in this i my default page i have to use name valuecollection and in my class i will have a method with two parameter (string table name,name value collection) and in the method my insert query should be so strong that i should not be change in table name change or new cols are added..
secondaly name valucollection should have key as column name and vaue to be inserted as key value...
only this namevalue clooection and tabename should be passed to the class method and in the method the insert query should should be fired so that records are inserted
Posted 24-Nov-12 0:30am
OriginalGriff 24-Nov-12 5:39am
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
Aqueel Ahmad 24-Nov-12 10:42am
i have told in the most appropriate way...its your problem that you are unable to understand
OriginalGriff 24-Nov-12 11:05am
"its your problem that you are unable to understand"

Not really.

I'm not the one waiting for an answer...
Nelek 24-Nov-12 14:08pm
If you think that's the most appropiate mode... then I don't want to ask what you consider the worst.

Just for your info: You are not having any punctuation signs (they help to understand the text), you have spelling errors, the gramatic is so bad than even me (non english speaker) see the errors.

And just to end... being rude with the best option you have to get an answer, that wasn't the best idea.
Aqueel Ahmad 25-Nov-12 2:02am
you are here to check spellings and English grammar or to resolve the problem... and i don't think so that you are not able to understand my problem... any how that's your problem.. if you can help me it will be my pleasure and if you are not able to help then also you are welcome......
Nelek 25-Nov-12 5:46am
No, I am not here to check spelling or grammar. And I don't care at all on how you write. But I DO care if I see an answer like yours to one of the most respected users in CP that help A LOT people like you for free, so the less you can do is to show a bit respect to the people helping.

If you say "I have told in the most appropiate way", then I will tell you... "no, you haven't, because of..." (as I did).

I just wanted to explain you the reason of my comment. If you understand it and learn from this situation... better for you. If not... I think you are going to do the things on your own, because with that attitude few people will be helping you.
HabeshaMan 26-Nov-12 17:42pm
Post sample code that could make it easy to understand.and please be respectful.
Paw Jershauge 24-Nov-12 17:03pm
Is it an codegenerator your lookin for or ???

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hello Aqueel,

So as i understand it...

You want to create a class,
and in your class you will have a method with two parameter
TableName as String and Collection of NameValue pairs

Also in your class will be a method to insert the data in the NameValue collection into the table named in TableName
And your VALIDATION should be so strong that the data cannot be changed in any way

Class MyClass
    Function InsertThisData(ByVal strTableName As String, ByVal colNVP As System.Collections.Specialized.NameValueCollection) As Boolean
        InsertThisData = False
        'check tablename is okay
        If Trim(strTableName) <> "" Then
            If (colNVP Is Nothing = False) Then
                If colNVP.Count > 0 Then
                    '1  build SQL INSERT query
                    '2  open connection using your connectionstring
                    '3      TRY
                    '4          Insert data into table
                    '5          InsertThisData = TRUE
                    '5      CATCH
                    '6          error - error whilst saving data
                    '7      END TRY
                    '4 - close connection
                    'Error - collection is empty
                End If
                'Error - collection is nothing/null
            End If
            'Error - TableName is missing
        End If
    End Function

End Class

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171114.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100