I've been trying to deal with this for a few hours. Here's my code.
To save some space I need to shorten my code. It seems that in my insert I cannot see the Tlat variable which is enclosed in the select statement. How can I use that variable so i can insert it.
Thanks.
SOME CODE HERE...............
string tlocquery = "SELECT LAC,CID,LONG,LAT,STREET,MUNICIPAL FROM TRIANGULATION WHERE lat LIKE " + "'%" + tlatcut.ToString() + "%' AND long LIKE '%" + tlongcut.ToString() + "%'";
SqlCommand commandtloc = new SqlCommand(tlocquery, cnn);
SqlDataReader sdrtloc = commandtloc.ExecuteReader();
while (sdrtloc.Read())
{
string Tlong = sdrtloc["LONG"].ToString();
txtbxTlong.Text = Tlong.ToString();
string Tlat = sdrtloc["LAT"].ToString();
txtbxTlat.Text = Tlat.ToString();
string Lac = sdrtloc["LAC"].ToString();
txtbxLac.Text = Lac.ToString();
string Cid = sdrtloc["CID"].ToString();
txtbxCid.Text = Cid.ToString();
string Street = sdrtloc["STREET"].ToString();
string Municipal = sdrtloc["MUNICIPAL"].ToString();
txtbxTloc.Text = Street.ToString() + "," + Municipal.ToString();
}
SOME CODE HERE...............
string insertquery = "INSERT INTO TBLCURRENT (TLONG,TLAT) VALUES ('" + Tlong + "','" + Tlat + "')";
SqlCommand insertcomm = new SqlCommand(insertquery, cnn);
SqlDataReader insertreader = insertcomm.ExecuteReader();