App>> sql

  • Thread starter Thread starter Johannes Matlaisane
  • Start date Start date
J

Johannes Matlaisane

I hate to submit codes, here it is below. This code only updates the
first letter not full. Check my previouse message.

Please dont change it too much>> by the way, I am new to this field. I
finish the course last and I am yet to write the exams.
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Save.Click
mycomm.CommandText = "Addsup"
mycomm.CommandType = CommandType.StoredProcedure
mycomm.Connection = myConn

Dim Suprecord1 As New SqlParameter("@SupName", txtSupName.Text)
Dim Suprecord2 As New SqlParameter("@SupContName",
txtSupContname.Text)
Dim Suprecord3 As New SqlParameter("@Suptel", txtsuptel.Text)
Dim Suprecord4 As New SqlParameter("@SupAdd1", txtSupadd1.Text)
Dim Suprecord5 As New SqlParameter("@SupAdd2", txtSupadd2.Text)
Dim Suprecord6 As New SqlParameter("@SupAdd3", txtSupadd3.Text)
Dim Suprecord7 As New SqlParameter("@SupAddCode",
txtSupCode.Text)


mycomm.Parameters.Add(Suprecord1)
mycomm.Parameters.Add(Suprecord2)
mycomm.Parameters.Add(Suprecord3)
mycomm.Parameters.Add(Suprecord4)
mycomm.Parameters.Add(Suprecord5)
mycomm.Parameters.Add(Suprecord6)
mycomm.Parameters.Add(Suprecord7)


Try
myConn.Open()
mycomm.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

myConn.Close()Stored procedure

create proc AddSup
(
@SupName varchar
,@SupContName varchar
,@Suptel varchar
,@SupAdd1 varchar
,@SupAdd2 varchar
,@SupAdd3 varchar
,@SupAddCode int
)

as

insert into SuppTable
(
SupName
,SupContName
,Suptel
,SupAdd1
,SupAdd2
,SupAdd3
,SupAddCode
)
values
(
@SupName
,@SupContName
,@Suptel
,@SupAdd1
,@SupAdd2
,@SupAdd3
,@SupAddCode
)
 
Try specifiying the size of the varchar variables.

Like
@SupName varchar(50)
and

mycomm.Parameters.Add("@SupName", System.Data.SqlDbType.VarChar, 50))

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top