I'm using visual studio 2010 and microsoft sql server 2008.
this is my procedure code:
PROCEDURE [dbo].[InsUpdUser]
(
@UID nchar(10),
@FName nchar(20),
@SName nchar(20),
@LName nchar(20),
@UT nchar(6),
@PWord nchar(4)
)
as
BEGIN
-- add NEW record
insert into UserT ([UID],FName,SName,LName,UT,PWord,QC)values(@UID,@FName,@SName,@LName,@UT,@PWord,0);
END
this the code for the class:
Public Class DataAccsess
Dim con As SqlConnection = New SqlConnection("Data Source=822-PC;Initial Catalog=ICDLDB;Integrated Security=True")
'open connection to the database
Public Sub dataAccess()
con.Open()
MsgBox("opend")
End Sub
'close the connection to the database
Public Sub CloseCon()
con.Close()
MsgBox("Closed")
End Sub
Public Sub addUsers(ByVal UID As String, ByVal fName As String, ByVal sName As String, ByVal lName As String, ByVal UserT As String, ByVal Pword As String)
Try
Dim PAS As String
Dim com As SqlCommand = New SqlCommand("InsUpdUser", con)
PAS = (UID).ToString.Substring(UID.ToString.Length - 4)
com.CommandType = CommandType.StoredProcedure
com.Parameters.Add(New SqlParameter("@UID", UID))
com.Parameters.Add(New SqlParameter("@FName", fName))
com.Parameters.Add(New SqlParameter("@SName", lName))
com.Parameters.Add(New SqlParameter("@LName", sName))
com.Parameters.Add(New SqlParameter("@UserT", UserT))
com.Parameters.Add(New SqlParameter("@Pword", PAS))
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End sub
End Class
the button code:
Try
Dim da As New DataAccess
da.opencon()
Dim ID, FN, SN, LN, UT, PWord As String
ID = TextBox2.Text
FN = TextBox3.Text
SN = TextBox4.Text
LN = TextBox5.Text
UT = DropDownList1.SelectedItem().Text
PWord = "0"
da.AddUser(ID, FN, SN, LN, UT, PWord)
da.closecon()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
So
the code run
I insert all the info in the textboxes and
the MsgBox("opened") pop up
then
the MsgBox("closed") pop up
nothing happened
no row inserted in the database
no row appear on the viewGrid.
nothing happened
I was using the express sql that come with the visual studio 2010, and the same thing happened.
my friend tell my to remove it and download the microsoft sql server 2008.
I did that but the same problem.
No Row add.
the procedure
was executed in the sql server.
when I create the connection.
the connection test pop up that connected successfully.
the connection in the run opened and closed.
but no row add.
hope I find any one can help me in this.
Thanks