1,105,391 Community Members

Argument not specified for parameter

Member Avatar
Lle26
Newbie Poster
4 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

The problem is in lies in TA.Insert(txtfirst.text)
I really dont know what is parameter,,,,all about
pls help me...pls

Public Class AddOutPatient

    Private Sub btncancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub

    Private Sub btnaddout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddout.Click
        'validation for firstname
        If txtfirst.Text.Trim = "" Then
            MsgBox("You should enter your firstname", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
            txtfirst.Focus()
            Exit Sub
        End If
        If txtfirst.Text.Contains(".") Then
            MsgBox("The name should include letters only", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
            txtfirst.Focus()
            Exit Sub
        End If

        'validation for lastname
        If txtlast.Text.Trim = "" Then
            MsgBox("You should enter your lastname", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
            txtlast.Focus()
            Exit Sub
        End If
        If txtlast.Text.Contains(".") Then
            MsgBox("The name should include letters only", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
            txtlast.Focus()
            Exit Sub
        End If

        'validation for age
        If txtage.Text.Contains("-") Then
            MsgBox("The age should only include digits only", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
            txtage.Focus()
            Exit Sub
        End If

        If Not IsNumeric(txtage.Text) Then
            MsgBox("The age should only include digits only", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
            txtage.Focus()
            Exit Sub
        End If

        'validation for sex
        If txtsex.Text.Trim = "" Then
            MsgBox("You should enter your sex", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
            txtlast.Focus()
            Exit Sub
        End If
        If txtsex.Text.Contains(".") Then
            MsgBox("The name should include letters only", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
            txtlast.Focus()
            Exit Sub
        End If


        'insert patient
        Try
            Dim TA As New DB1DataSet1TableAdapters.OutPatient_infoTableAdapter

            TA.Insert(txtfirst.Text)
            'close window and return ok
            Me.DialogResult = Windows.Forms.DialogResult.OK
        Catch ex As Exception
            'display error message
            MsgBox(ex.Message, MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
        End Try
    End Sub
End Class
Member Avatar
M.Waqas Aslam
Practically a Posting Shark
837 posts since Aug 2011
Reputation Points: 67 [?]
Q&As Helped to Solve: 137 [?]
Skill Endorsements: 4 [?]
Featured
 
0
 

hello !
there is no time to read your full code , please let me know , do you want to know how to insert record in database ?

Member Avatar
Lle26
Newbie Poster
4 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

hello !
there is no time to read your full code , please let me know , do you want to know how to insert record in database ?

Yes pls...can you help me pls

Member Avatar
M.Waqas Aslam
Practically a Posting Shark
837 posts since Aug 2011
Reputation Points: 67 [?]
Q&As Helped to Solve: 137 [?]
Skill Endorsements: 4 [?]
Featured
 
0
 

hello !
you want to insert records in db , there are some steps you have to follow.
1-you have to import class at the top of your form .here is the code

import system.data.sqlclient
'NOTE:please type this code at the top .

after doing this , you have to understand little bit about the components you will use for inserting records.
--SqlConnection - it is used to connect your application with your database.
--sqlCommand - Represents a Transact-SQL statement or stored procedure to execute against a SQL Server database.
--Connection String -A connection string is a string version of the initialization properties needed to connect to a data store and enables you to easily store connection information within your application or to pass it between applications.
now here is code and step by step description .

'after importing system.data.sqlclient
'we have to connect our application with db , for this we use connection string ,
'Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
'above is a connection string 
'now start connection
dim myCon as new sqlconnection("Data Source=waqas/sqlexpress;Initial Catalog=myDataBase;Integrated Security=SSPI;")
'here you have to give your server , and your database name ,as i give.
'after connection there are two states of your connection , a open state and close state.
'now we make a insert command to insert records in database.
dim cmd as new sqlcommand
'now set your connection open 
myCon.open()
cmd.connection = myCon
'here we make a command
cmd.commandtext = "insert into table (StudentID,StudentName,Age,Gender) valuse (@StudentID,@StudentName,@Age,@Gender)"
'now give values you want to insert like this
cmd.Parameters .AddWithValue(@StudentID,val(txtStudentid.text))'NOTE:always use val() when you are dealing with integer , decimal, in this case i assume that we have datatype of studentid field in database is int.
cmd.Parameters .AddWithValue(@StudentName,txtStudentName.text)
cmd.Parameters .AddWithValue(@Age,txtAge.text)
cmd.Parameters .AddWithValue(@Gender,txtGender.text)'i assume that student name , age and gender are varchar datatype in my database so i not use val() here
'now execute this query to insert your records
cmd.ExecuteNonQuery()
'now close the connection
myCon.Close()

this code will insert your records in your database ,hope this will helps you to understand the whole procedure of insertion in database , you can further find all information about sqlconnection here http://msdn.microsoft.com/en-us/libr...onnection.aspx and about sqlcommand here http://msdn.microsoft.com/en-us/libr...qlcommand.aspx and about connection string from here http://www.connectionstrings.com and from here http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx .
hope this will helps you and others , if you find any mistake init please do tell me .

Best Regards

Member Avatar
M.Waqas Aslam
Practically a Posting Shark
837 posts since Aug 2011
Reputation Points: 67 [?]
Q&As Helped to Solve: 137 [?]
Skill Endorsements: 4 [?]
Featured
 
0
 

if you are using access , then this is the same logic , which you need, so before writing code it is imp to know what you need to do to complete your task , if you need any other information then please also do tell .

GOD Bless you,

Regards

Question Answered as of 1 Year Ago by M.Waqas Aslam
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: