guysoul
10-10-2011, 03:28 AM
Hi everyone,
Im new to vb.net and I need help on how to create a conditional statement if the value of rows is zero or not.
I want my output to something like... IF the value is zero, an sms message will be sent to the client that he is not registered ELSE an sms message will be sent containing his new autogeneration code. Been working on this for a month but i have no luck. I came to cross with your forum and I hope someone can help me with this.
Here's my code:
Private Sub CheSMS()
Dim SQLServer As String = My.Settings.SQLServer
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim da As SqlDataAdapter = Nothing
Dim ds As DataSet = New DataSet
Dim dr As DataRow = Nothing
conn = New SqlConnection(SQLServer)
conn.Open()
'checks if the customer is a registered user
cmd = New SqlCommand("SELECT * FROM SMSIn JOIN SMSService ON SMSIn.Originator = SMSService.GSMNo WHERE SMSIn.SMSText LIKE 'TDS SR%' AND SMSIn.SMSStatus = 'Motatt'", conn)
Try
da = New SqlDataAdapter(cmd)
da.Fill(ds, "SMS")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Dim obj = cmd.ExecuteScalar
MessageBox.Show(obj)
'this code describes how to validate rowtables with results return and rowtables that doesnt return any results (0)
Dim J As Integer = ds.Tables(0).Rows.Count
For I As Integer = 0 To J
dr = ds.Tables(0).Rows(0)
If Not obj Is Nothing AndAlso obj Is DBNull.Value Then
GenCodeAndSendSMSNotRegistered(dr("Originator"), dr("SMSText"), dr("ID"))
Else
GenCodeAndSendSMS(dr("Originator"), dr("SMSText"), dr("ID"))
End If
Next I
conn.Close()
conn = Nothing
cmd = Nothing
End Sub
Thanks,
Ed
Im new to vb.net and I need help on how to create a conditional statement if the value of rows is zero or not.
I want my output to something like... IF the value is zero, an sms message will be sent to the client that he is not registered ELSE an sms message will be sent containing his new autogeneration code. Been working on this for a month but i have no luck. I came to cross with your forum and I hope someone can help me with this.
Here's my code:
Private Sub CheSMS()
Dim SQLServer As String = My.Settings.SQLServer
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim da As SqlDataAdapter = Nothing
Dim ds As DataSet = New DataSet
Dim dr As DataRow = Nothing
conn = New SqlConnection(SQLServer)
conn.Open()
'checks if the customer is a registered user
cmd = New SqlCommand("SELECT * FROM SMSIn JOIN SMSService ON SMSIn.Originator = SMSService.GSMNo WHERE SMSIn.SMSText LIKE 'TDS SR%' AND SMSIn.SMSStatus = 'Motatt'", conn)
Try
da = New SqlDataAdapter(cmd)
da.Fill(ds, "SMS")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Dim obj = cmd.ExecuteScalar
MessageBox.Show(obj)
'this code describes how to validate rowtables with results return and rowtables that doesnt return any results (0)
Dim J As Integer = ds.Tables(0).Rows.Count
For I As Integer = 0 To J
dr = ds.Tables(0).Rows(0)
If Not obj Is Nothing AndAlso obj Is DBNull.Value Then
GenCodeAndSendSMSNotRegistered(dr("Originator"), dr("SMSText"), dr("ID"))
Else
GenCodeAndSendSMS(dr("Originator"), dr("SMSText"), dr("ID"))
End If
Next I
conn.Close()
conn = Nothing
cmd = Nothing
End Sub
Thanks,
Ed