Server Error in '/' Application. connection database - visual-studio

please help me
is SYNTAX ERROR? or... database problem?
I can't find the problem
[

I'm sorry I didn't write clearly
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class account_login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Login_Click(object sender, EventArgs e)
{
SqlConnection Conn = new SqlConnection("Server=163.17.9.63;Database=DB1_xx;User Id=DB1_xx;Password=DB1_xx; ");
Conn.Open();
SqlDataReader dr;
SqlCommand cmd = new SqlCommand("Select * From db_account Where account='" + account.Text + "' and password = '" + password.Text + "'", Conn);
dr = cmd.ExecuteReader();
if (!dr.Read())
{
Label1.Text = "error!";
cmd.Cancel();
dr.Close();
Conn.Close();
Conn.Dispose();
}
else
{
Session["Login"] = "OK";
Session["name"] = dr["name"].ToString();
Session["rank"] = dr["rank"].ToString();
cmd.Cancel();
dr.Close();
Conn.Close();
Conn.Dispose();
Response.Write("<script>alert('success!!!');location.href='../main.aspx'</script>");
}
}
}

Related

Why client program can read user's cloud data through Google Drive API even after deleting all projects from developer console of my account?

Why the client program can read user's Google Drive Data through Google Drive API even after deleting all Google Cloud Platform Projects of my account?
Is it something like that?
Is it possible to prevent user from using the client program?
Source code.
using Google.Apis.Auth.OAuth2;
using Google.Apis.Drive.v3;
using Google.Apis.Drive.v3.Data;
using Google.Apis.Services;
using Google.Apis.Util.Store;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GoogleDriveTest
{
public partial class Form1 : Form
{
private string[] Scopes = {
DriveService.Scope.Drive,
DriveService.Scope.DriveFile,
DriveService.Scope.DriveMetadata
};
private const string ApplicationName = "Quickstart";
private UserCredential credential;
public DriveService service;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
GetAuth();
}
private void button1_Click(object sender, EventArgs e)
{
string x = GetFile("DocumentName");
}
private void button2_Click(object sender, EventArgs e)
{
}
public void GetAuth()
{
using (var stream =
new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
{
string credPath = "token.json";
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)
).Result;
//_userCredential = credentials.Result;
//if (credentials.IsCanceled || credentials.IsFaulted)
// throw new Exception("cannot connect");
service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
}
}
public string GetFile(string file_name)
{
FilesResource.ListRequest req = service.Files.List();
do
{
//req.Q = "title='" + file_name + "'";
req.Q = "name='" + file_name + "'";
FileList file_search = req.Execute();
foreach (Google.Apis.Drive.v3.Data.File a in file_search.Files)
{
System.Windows.Forms.MessageBox.Show(a.Id);
return a.Id;
}
} while (!String.IsNullOrEmpty(req.PageToken));
return "";
}
}
}
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........

Getting error in Google contacts API

I am working on Google Apps for Education to integrate with my .net application.I want to integrate google contacts to my application.For that i am using below code
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Google.GData.Contacts;
using Google.GData.Client;
using Google.GData.Extensions;
using Google.Contacts;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public static DataSet GetGmailContacts(string App_Name, string Uname, string UPassword)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
DataColumn C2 = new DataColumn();
C2.DataType = Type.GetType("System.String");
C2.ColumnName = "EmailID";
dt.Columns.Add(C2);
RequestSettings rs = new RequestSettings(App_Name, Uname, UPassword);
rs.AutoPaging = true;
ContactsRequest cr = new ContactsRequest(rs);
Feed<Contact> f = cr.GetContacts();
foreach (Contact t in f.Entries)
{
foreach (EMail email in t.Emails)
{
DataRow dr1 = dt.NewRow();
dr1["EmailID"] = email.Address.ToString();
dt.Rows.Add(dr1);
}
}
ds.Tables.Add(dt);
return ds;
}
protected void Button1_Click(object sender, EventArgs e)
{
DataSet ds = GetGmailContacts("MyNetwork Web Application!", txtgmailusername.Text, txtpassword.Text);
gvmails.DataSource = ds;
gvmails.DataBind();
}
}
When i execute the above code i am getting below error.
"Execution of authentication request returned unexpected result: 404"
How to solve this error.please help me on this...

Insert, Update, Delete query using LINQ in datagridview in C# Windows Programming?

Scenario: There is following controls in the form:
datagridview, textbox1, textbox2, button(save,edit,update,delete)
1.By clicking on save button, data should be updated into datagridview at run-time.
2.By selecting complete row and clicking on edit button, data should be retrieved into textboxes.
3.By clicking on Update button, that data should be updated.
4.By selecting a complete row, the row should be deleted.
This is my code.
I hope it will help you
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace LINQ_Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
LINQtestDataContext dc = new LINQtestDataContext();
public void show_data()
{
dataGridView1.DataSource = (from t in dc.LinqTests
select t);
}
public void insert_data()
{
try
{
LinqTest tbl = new LinqTest
{
ID=Convert.ToInt32(textBox_id.Text),
Name=textBox_name.Text
};
dc.LinqTests.InsertOnSubmit(tbl);
dc.SubmitChanges();
MessageBox.Show("Data Inserted!!!");
show_data();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public void update_data()
{
try
{
LinqTest tbl = dc.LinqTests.Single(x=>x.ID==Convert.ToInt32(textBox_id.Text));
tbl.Name = textBox_new_name.Text;
dc.SubmitChanges();
MessageBox.Show("Data Updated!!!");
show_data();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public void delete_data()
{
try
{
LinqTest tbl = dc.LinqTests.Single(x => x.ID == Convert.ToInt32(textBox_id.Text));
dc.LinqTests.DeleteOnSubmit(tbl);
dc.SubmitChanges();
MessageBox.Show("Data Deleted!!!");
show_data();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void Form1_Load(object sender, EventArgs e)
{
show_data();
}
private void button_insert_Click(object sender, EventArgs e)
{
insert_data();
}
private void button_update_Click(object sender, EventArgs e)
{
update_data();
}
private void button_delete_Click(object sender, EventArgs e)
{
delete_data();
}
}
}

How to make back button return to the system Windows Phone

I have a small app there is 3 seconds intro page, then the content page. When I push back button I go back to the intro screen, but I think I should go back to the system. How to do it?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.ServiceModel.Syndication;
using System.Xml;
using Microsoft.Phone.Tasks;
namespace RSS {
public partial class FeedPage : PhoneApplicationPage {
public FeedPage() {
InitializeComponent();
this.Loaded += new RoutedEventHandler(PhonePage1_Loaded);
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) {
clearBackStack();
base.OnNavigatedTo(e);
}
void clearBackStack() {
while (this.NavigationService.BackStack.Any()) {
this.NavigationService.RemoveBackEntry();
}
}
void PhonePage1_Loaded(object sender, RoutedEventArgs e) {
// clearBackStack();
WebClient wc = new WebClient();
wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
wc.OpenReadAsync(new Uri("http://www.carmagazine.co.uk/Shared/Handlers/RssHandler.ashx?&N=190&Ns=P_Publication_Date|1&?"));
}
void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) {
SyndicationFeed feed;
try {
using (XmlReader reader = XmlReader.Create(e.Result)) {
feed = SyndicationFeed.Load(reader);
lista.ItemsSource = feed.Items;
}
} catch (WebException we) { MessageBox.Show("Internet connection is down.");}
}
private void Button_Click(object sender, System.Windows.RoutedEventArgs e) {
WebBrowserTask webBrowserTask = new WebBrowserTask();
String url = (String)((Button)sender).Tag;
webBrowserTask.Uri = new Uri(url);
webBrowserTask.Show();
}
}
}
You should clear the BackStack in the OnNavigateTo method of your content page
while (this.NavigationService.BackStack.Any())
{
this.NavigationService.RemoveBackEntry();
}
The following code is the best practice for the back button key press.
protected override void OnBackKeyPress(CancelEventArgs e)
{
while (NavigationService.CanGoBack)
NavigationService.RemoveBackEntry();
base.OnBackKeyPress(e);
}
This ensures that your application will exit and return to the main screen on pressing the BackKey.

Taking screenshot of windows phone 7.5 and sending over through TCP

i am stuck on how to take a screenshot of my windows phone 7.5 and sending it over TCP. i have no experience in doing socket program and I/O and am doing what i can through tutorials over the internet. This is what i have done.
From the codes below i am stuck in how i can send the writeableBitMap over TCP encoded as a Jpeg periodically running in the WP7.5 background, whereby a program on a desktop will receive it as a jpeg image so it can be displayed creating a windows phone to desktop streaming effect.
my mainPage of my windows phone 7.5 application using a library i have created from a tutorial for taking care of the sockets connection.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone;
using System.Windows.Media;
using System.IO;
namespace helloworld
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
SocketLibrary.socketLib sl = new SocketLibrary.socketLib();
private string hostIP = "127.0.0.1";
public MainPage()
{
InitializeComponent();
}
private void btnConnect_Click(object sender, RoutedEventArgs e)
{
bool retVal;
retVal = sl.EstablishTCPConnection(hostIP);
WriteableBitmap bmpCurrentScreenImage = new WriteableBitmap((int)this.ActualWidth, (int)this.ActualHeight);
var ms = new MemoryStream();
// Send the picture.
bmpCurrentScreenImage.SaveJpeg(ms, bmpCurrentScreenImage.PixelWidth, bmpCurrentScreenImage.PixelHeight, 0, 90);
ms.Seek(0, SeekOrigin.Begin);
retVal = sl.Send(ms);
sl.CloseSocket();
}
}
}
the socket library
namespace SocketLibrary
{
public class socketLib
{
Socket s = null;
static ManualResetEvent done = new ManualResetEvent(false);
private Int16 portNo = 3334;
public socketLib()
{
}
public bool EstablishTCPConnection(string host)
{
s = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs();
socketEventArg.RemoteEndPoint = new DnsEndPoint(host, portNo);
socketEventArg.Completed += new
EventHandler<SocketAsyncEventArgs>(delegate(object o, SocketAsyncEventArgs e)
{
done.Set();
});
done.Reset();
s.ConnectAsync(socketEventArg);
return done.WaitOne(10000);
}
public bool Send(MemoryStream data)
{
byte[] msData = data.ToArray();
if (s != null)
{
SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs();
socketEventArg.RemoteEndPoint = s.RemoteEndPoint;
socketEventArg.UserToken = null;
socketEventArg.Completed += new
EventHandler<SocketAsyncEventArgs>(delegate(object o, SocketAsyncEventArgs e)
{
done.Set();
});
socketEventArg.SetBuffer(msData, 0, msData.Length);
done.Reset();
s.SendAsync(socketEventArg);
return done.WaitOne(10000);
}
return false;
}
public void CloseSocket()
{
if (s != null)
{
s.Close();
}
}
}
}
check this
http://www.charlespetzold.com/blog/2011/05/Windows-Phone-Screen-Shots.html
http://blog.galasoft.ch/archive/2010/12/28/taking-a-screenshot-from-within-a-silverlight-wp7-application.aspx

Resources