Hello, I am not able to save the data in the database !, the data is displaying normally but I can not extract them from the Label, I am using mySQL and WebForms.
GoogleDB.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
/// <summary>
/// Descrição resumida de GoogleDB
/// </summary>
public class GoogleDB
{
public GoogleDB()
{
//
// TODO: Adicionar lógica do construtor aqui
//
}
public static int InsertLogin(GoogleProfile usuario)
{
int retorno = 0;
try
{
IDbConnection conexao;
IDbCommand comando;
string sql = "insert into usu_usuario values(0, ?usu_id_google, ?usu_nome, ?usu_email, ?usu_sexo, ?usu_tipo); select last_insert_id();";
conexao = Mapped.Connection();
comando = Mapped.Command(sql, conexao);
comando.Parameters.Add(Mapped.Parameter("?usu_id_google", usuario.Id));
comando.Parameters.Add(Mapped.Parameter("?usu_nome", usuario.DisplayName));
comando.Parameters.Add(Mapped.Parameter("?usu_email", usuario.Emails));
comando.Parameters.Add(Mapped.Parameter("?usu_sexo", usuario.Gender));
comando.Parameters.Add(Mapped.Parameter("?usu_tipo", usuario.ObjectType));
retorno = Convert.ToInt32(comando.ExecuteScalar());
conexao.Close();
comando.Dispose();
conexao.Dispose();
}
catch (Exception e)
{
retorno = -2;
}
return retorno;
}
}
web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please
visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
<add key="strConexao" value="Database=login_google; Data Source=localhost;user id=root; Password=root; pooling=false;"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
</configuration>
MySQL Code
#DROP DATABASE login_google;
CREATE database login_google;
USE login_google;
CREATE TABLE usu_usuario(
usu_id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
usu_id_google INT NOT NULL,
usu_nome VARCHAR(100) NOT NULL,
usu_email VARCHAR(100),
usu_sexo VARCHAR(8),
usu_tipo VARCHAR(10)
);