Stuart Marshall
Member
Hi there
I'm very new to these forums so I hope I'm posting this in the right place, my apologies if I am not.
I've been learning VB.net for about 2 months now and very recently I have been working with VB.net and SQL databases.
I have a data tier that allows me to connect to a SQL database. Below is the code I have written showing my attempt to display a value gained from a count select statement in another form within the same project. But it is reporting a problem with the format of the value I am trying to display.... can anybody help me?
-----------------------------
Public Sub CountValue()
Dim objConnection As DataTier.Connection
Dim objQueryCount As DataTier.Query
Dim countsql As Long
Dim Selected As Integer
Selected = Me.grdData.SelectedRows(0).Cells("eMailGroup_ID").Value
countsql = ("SELECT COUNT(eMailTransaction_ID) AS Exp1 FROM tblEmailTransaction WHERE (eMailGroup_ID = " + Selected + ")")
Try
' Generate a count value
objConnection = New DataTier.Connection("CAPRi_Beta_01", "PC08009")
objQueryCount = objConnection.CreateQuery(countsql)
If objQueryCount.Execute() Then
add.TxtCount.Text = countsql
Else
MessageBox.Show(objConnection.LastError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Catch ex As Exception
MessageBox.Show(ex.ToString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
countsql = Nothing
Selected = Nothing
objConnection = Nothing
objQueryCount = Nothing
End Sub
---------------------------------------------------
I'm fairly sure it's something to do with the .tostring extension, but I'm really confused on this one.
thanks for your help
Stuart Marshall
I'm very new to these forums so I hope I'm posting this in the right place, my apologies if I am not.
I've been learning VB.net for about 2 months now and very recently I have been working with VB.net and SQL databases.
I have a data tier that allows me to connect to a SQL database. Below is the code I have written showing my attempt to display a value gained from a count select statement in another form within the same project. But it is reporting a problem with the format of the value I am trying to display.... can anybody help me?
-----------------------------
Public Sub CountValue()
Dim objConnection As DataTier.Connection
Dim objQueryCount As DataTier.Query
Dim countsql As Long
Dim Selected As Integer
Selected = Me.grdData.SelectedRows(0).Cells("eMailGroup_ID").Value
countsql = ("SELECT COUNT(eMailTransaction_ID) AS Exp1 FROM tblEmailTransaction WHERE (eMailGroup_ID = " + Selected + ")")
Try
' Generate a count value
objConnection = New DataTier.Connection("CAPRi_Beta_01", "PC08009")
objQueryCount = objConnection.CreateQuery(countsql)
If objQueryCount.Execute() Then
add.TxtCount.Text = countsql
Else
MessageBox.Show(objConnection.LastError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Catch ex As Exception
MessageBox.Show(ex.ToString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
countsql = Nothing
Selected = Nothing
objConnection = Nothing
objQueryCount = Nothing
End Sub
---------------------------------------------------
I'm fairly sure it's something to do with the .tostring extension, but I'm really confused on this one.
thanks for your help
Stuart Marshall