i have this connection string
<connectionStrings>
<add name="Tendering_Pro" connectionString="Data Source=HABOUSH-PC\SQLEXPRESS;Initial Catalog=TenderingProgram;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.diagnostics>
AND THIS MY CLAAS :
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Public Class BuyNewTender
Private conn As SqlConnection
Private _MSG As String = ""
Private _ProjectTenderingNO As String = ""
Private _TenderingNo As String = ""
Private _ProjectName As String = ""
Private _Clientname As String = ""
Private _PurchasePrice As Integer = 0
Private _BuyDate As String = ""
Private _TenderClosingDate As String = ""
Private _DocumentDetail As String = ""
Private _Notes As String = ""
Public Property ProjectTenderingNO() As String
Get
Return _ProjectTenderingNO
End Get
Set(ByVal value As String)
_ProjectTenderingNO = value
End Set
End Property
Public Property ProjectName() As String
Get
Return _ProjectName
End Get
Set(ByVal value As String)
_ProjectName = value
End Set
End Property
Public Property TenderingNO() As String
Get
Return _TenderingNo
End Get
Set(ByVal value As String)
_TenderingNo = value
End Set
End Property
Public Property Clientname() As String
Get
Return _Clientname
End Get
Set(ByVal value As String)
_Clientname = value
End Set
End Property
Public Property PurchasePrice() As Integer
Get
Return _PurchasePrice
End Get
Set(ByVal value As Integer)
_PurchasePrice = value
End Set
End Property
Public Property BuyDate() As String
Get
Return _BuyDate
End Get
Set(ByVal value As String)
_BuyDate = value
End Set
End Property
Public Property TenderClosingDate() As String
Get
Return _TenderClosingDate
End Get
Set(ByVal value As String)
_TenderClosingDate = value
End Set
End Property
Public Property DocumentDetail() As String
Get
Return _DocumentDetail
End Get
Set(ByVal value As String)
_DocumentDetail = value
End Set
End Property
Public Property Notes() As String
Get
Return _Notes
End Get
Set(ByVal value As String)
_Notes = value
End Set
End Property
Public ReadOnly Property GetMSG() As String
Get
Return _MSG
End Get
End Property
Private Sub GetConnection()
Dim DbConnection As String = System.Configuration.ConfigurationManager.ConnectionStrings("Tendering_Pro").ConnectionString
Try
Me.conn = New SqlConnection(DbConnection)
Me.conn.Open()
Catch ex As Exception
Me._MSG = ex.Message
End Try
End Sub
Public Sub add()
GetConnection()
Dim sql As String = "INSERT INTO [BuyNewTender] "
sql = sql & "([ProjectTenderingNO]"
sql = sql & " ,[TenderingNo]"
sql = sql & " ,[ProjectName]"
sql = sql & " ,[Clientname]"
sql = sql & " ,[PurchasePrice]"
sql = sql & " ,[BuyDate]"
sql = sql & " ,[TenderClosingDate]"
sql = sql & " ,[DocumentDetail]"
sql = sql & " ,[Notes])"
sql = sql & " VALUES()"
sql = sql & " (@ProjectTenderingNO"
sql = sql & " ,@TenderingNo"
sql = sql & " ,@ProjectName"
sql = sql & " ,@Clientname"
sql = sql & " ,@PurchasePrice"
sql = sql & " ,@BuyDate"
sql = sql & " ,@TenderClosingDate"
sql = sql & " ,@DocumentDetail]"
sql = sql & " ,@Notes)"
Dim cmd As New SqlCommand(sql, conn)
cmd.Parameters.Add("@ProjectTenderingNO", SqlDbType.NVarChar).Value = _ProjectTenderingNO
cmd.Parameters.Add("@TenderingNo", SqlDbType.NVarChar).Value = _TenderingNo
cmd.Parameters.Add("@ProjectName", SqlDbType.NVarChar).Value = _ProjectName
cmd.Parameters.Add("@Clientname", SqlDbType.NVarChar).Value = _Clientname
cmd.Parameters.Add("@PurchasePrice", SqlDbType.Int).Value = _PurchasePrice
cmd.Parameters.Add("@BuyDate", SqlDbType.Date).Value = _BuyDate
cmd.Parameters.Add("@TenderClosingDate", SqlDbType.Date).Value = _TenderClosingDate
cmd.Parameters.Add("@DocumentDetail", SqlDbType.NVarChar).Value = _DocumentDetail
cmd.Parameters.Add("@Notes", SqlDbType.NVarChar).Value = _Notes
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
Me._MSG = ex.Message
Finally
If conn.State = ConnectionState.Open Then
conn.Close()
End If
End Try
End Sub
END CLASS
AND THIS IS INSIDE ADD BUTTON
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim objBuyNewTender As New BuyNewTender
If (txtProjectTNO.Text Is Nothing) Then
objBuyNewTender.ProjectTenderingNO = ""
Else
objBuyNewTender.ProjectTenderingNO = txtProjectTNO.Text
End If
If (txtTenderNO.Text Is Nothing) Then
objBuyNewTender.TenderingNO = ""
Else
objBuyNewTender.TenderingNO = txtTenderNO.Text.ToString
End If
If (txtProjectName.Text Is Nothing) Then
objBuyNewTender.ProjectName = ""
Else
objBuyNewTender.ProjectName = txtProjectName.Text
End If
If (txtClientName.Text Is Nothing) Then
objBuyNewTender.Clientname = ""
Else
objBuyNewTender.Clientname = txtClientName.Text
End If
If (txtPurchasePrice.Text Is Nothing) Then
objBuyNewTender.PurchasePrice = 0
Else
objBuyNewTender.PurchasePrice = txtPurchasePrice.Text
End If
If (DTPBuyDate.Text Is Nothing) Then
objBuyNewTender.BuyDate = ""
Else
objBuyNewTender.BuyDate = DTPBuyDate.Text
End If
If (DTPTenderingClosing.Text Is Nothing) Then
objBuyNewTender.TenderClosingDate = ""
Else
objBuyNewTender.TenderClosingDate = DTPTenderingClosing.Text
End If
If (txtDocumentDetail.Text Is Nothing) Then
objBuyNewTender.DocumentDetail = ""
Else
objBuyNewTender.DocumentDetail = txtDocumentDetail.Text
End If
If (txtNotes.Text Is Nothing) Then
objBuyNewTender.Notes = ""
Else
objBuyNewTender.Notes = txtNotes.Text
End If
objBuyNewTender.add()
MessageBox.Show("Project Defintion Saved Successfully")
BUT THERE IS NO ERROR AND THERE IS NO DATA SAVED TO SQL SERVER , CAN SOME ONE TELL ME WHY ??
HibaPro -3 Junior Poster
lolafuertes 145 Master Poster
Reverend Jim commented: Good to see you back.. We missed you. +11
HibaPro -3 Junior Poster
lolafuertes 145 Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.