Click here to Skip to main content
15,902,832 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
this is what i made until now but a don't now to finish the function
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Public Class Salariat
    Dim m_cnp As String
    Dim m_nume As String
    Dim m_prenume As String
    Dim m_adresa As String
    Dim m_telefon As String
    Dim m_calificare As String
    Dim m_contBancar As String
    Public Property cnp() As String
        Get
            Return m_cnp
        End Get
        Set(ByVal value As String)
            If Len(value) = 13 Then
                m_cnp = value
            Else
                Throw New Exception("CNP incorect!")
            End If
        End Set
    End Property
    Public Property nume() As String
        Get
            Return m_nume
        End Get
        Set(ByVal value As String)
            If value <> "" Then
                m_nume = value
            Else
                Throw New Exception("Completati Numele!")
            End If
        End Set
    End Property
    Public Property prenume() As String
        Get
            Return m_prenume
        End Get
        Set(ByVal value As String)
            If value <> "" Then
                m_prenume = value
            Else
                Throw New Exception("Completati Prenumele!")
            End If
        End Set
    End Property
    Public Property adresa() As String
        Get
            Return m_adresa
        End Get
        Set(ByVal value As String)
            m_adresa = value
        End Set
    End Property
    Public Property telefon() As String
        Get
            Return m_telefon
        End Get
        Set(ByVal value As String)
            m_telefon = value
        End Set
    End Property
    Public Property calificare() As String
        Get
            Return m_calificare
        End Get
        Set(ByVal value As String)
            m_calificare = value
        End Set
    End Property
    Public Property contBancar() As String
        Get
            Return m_contBancar
        End Get
        Set(ByVal value As String)
            If Len(value) = 24 Then
                m_contBancar = value
            Else
                Throw New Exception("Cont bancar incorect!")
            End If
        End Set
    End Property
    Public Sub Adauga()
        Dim cmd As New SqlCommand
        Dim sCnnection As String = "server=(local);Integrated Security=SSPI;database=crossal"
        Dim cnn As New SqlConnection With {.ConnectionString = sCnnection}
        cnn.Open()
        cmd.Connection = cnn
    End Sub
End Class
Posted
Updated 11-Apr-11 4:01am
v2

You need to design the database table structure first.
Once that is done, you need to save the values of the properties you have here into the database.

Do a search on the internet. There are tons of articles describing this.
Try something out. If you run into any issues, post them here.
 
Share this answer
 
Comments
Daniel Crosman 11-Apr-11 10:25am    
i have created the structure ... my problem it was filling it with the values of properties
Try this:

Public Sub Adauga()
        Dim cmd As New SqlCommand
        Dim sCnnection As String = "server=(local);Integrated Security=SSPI;database=crossal"
        Dim cnn As New SqlConnection With {.ConnectionString = sCnnection}
        cnn.Open()
        cmd.Connection = cnn
        cmd.CommandText = "INSERT INTO tableName (CNP, Nume, Prenume, Adresa, Telefon, Calificare, Contbancar) VALUES (@CNP, @Nume, @Prenume, @Adresa, @Telefon, @Calificare, @Contbancar)"
        cmd.Parameters.AddWithValue("@CNP", Me.cnp)
        cmd.Parameters.AddWithValue("@Nume", Me.nume)
        'Add rest of members as parameters like this
        cmd.ExecuteNonQuery()
        cnn.Close()
    End Sub



Hope this helps
 
Share this answer
 
v3
Comments
Daniel Crosman 11-Apr-11 10:23am    
thanks
Wayne Gaylard 11-Apr-11 10:23am    
Pleasure.
Daniel Crosman 12-Apr-11 5:07am    
Your solution worked perfectly ... thanks again
but i am having another problem ...
I want to make a function function1 that fill a checked list box with objects contained in database and to use it after that to select an object for deleting or modifying.
It will be great if i make a function, function2 (with one parameter(Cnp), attribute witch is primary key in data table ) in the class and this function fill all the attributes of object.
In the form to call this function, function2 recurring in the firs function, function1 that i was telling you about.

I hope i described correct my problem so you can understand it.
I am sorry that i am bothering you bun i am a beginner with ado.net and with vb.net in general.
Thank you

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900