I have a simple SQL command that wont work in certain giving parameters.
For example if TweetID = 59
and UserID = 1
it will return the value;
but if TweetID = 8
and UserID = 1
it will not return the value.
Can some one find the reason for that?
public static int GetReTweetIdFromReTweetByUserIdAndTweetId(int TweetID,int UserID)
{
string sql = "SELECT [ReTweetID] FROM [ReTweet] WHERE [TweetID] = [@TID] AND [UserID] = [@UID]";
OleDbConnection conn = ConnectToDb();
OleDbCommand com = new OleDbCommand(sql, conn);
com.Parameters.Clear();
OleDbParameter objParamater;
objParamater = com.Parameters.Add("[@UID]", OleDbType.Integer);
objParamater.Direction = ParameterDirection.Input;
objParamater.Value = UserID;
objParamater = com.Parameters.Add("[@TID]", OleDbType.Integer);
objParamater.Direction = ParameterDirection.Input;
objParamater.Value = TweetID;
OleDbDataAdapter da = new OleDbDataAdapter(com);
DataTable dt = new DataTable();
int id=0;
try
{
conn.Open();
da.Fill(dt);
id = int.Parse(dt.Rows[0][0].ToString());
}
catch (Exception err)
{
throw err;
}
finally
{
da.Dispose();
dt.Dispose();
com.Dispose();
conn.Close();
conn.Dispose();
}
return id;
}