ive got problem with storing result of SELECT query in vb.net. im using sql.
i want to use database_A result query as an argument in another database_B.
i want to know how..could you please help me.
what i have try to do is try to store select query from db_A in a variable.
and call it in query for db_B. but ive got error and i dunno the right way to do that
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim PubsConn As New System.Data.SqlClient.SqlConnection( _
"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\Administrator\Desktop\pojekPSM\sistemPengesanan\sistemPengesanan\passenger.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
Dim cmd As New SqlCommand()
cmd.CommandText = "SELECT No_Tel FROM PassengerInfo WHERE Masa_Menunggu >='" & DateAndTime.Now & "' and Masa_DiScan is null"
cmd.Connection = PubsConn
PubsConn.Open()
Dim tel As SByte
tel = cmd.ExecuteNonQuery
'MessageBox.Show(tel)
PubsConn.Close()
Dim myConnection As New SqlConnection("Data Source=USER-0B4511E87F\SQLEXPRESS;Initial Catalog=ozeki;Integrated Security=True")
Dim mySqlQuery As String = "INSERT INTO ozekimessageout (receiver,msg,status) " _
& "VALUES ('" & tel & "', 'test', 'send');"
Dim mySqlCommand As New SqlCommand(mySqlQuery, myConnection)
myConnection.Open()
mySqlCommand.ExecuteNonQuery()
myConnection.Close()
End Sub
the tel variable return -1..the result should be telephone number(ie, +60123456789).please help me..URGENT=(