Jump to content
7H3PRO

C# si SQL

Recommended Posts

Am codu asta:


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.Tasks;
using System.Windows.Forms;
using Finisar.SQLite;

namespace WindowsFormsApplication1
{

public partial class Form1 : Form
{
private SQLiteConnection sql_con;
private SQLiteCommand sql_cmd;
private DataSet DS = new DataSet();
private DataTable DT = new DataTable();

private void SetConnection()
{
sql_con = new SQLiteConnection("Data Source=data;Version=3;New=True;Compress=True;");
}

private void ExecuteQuery(string txtQuery)
{
SetConnection();
sql_con.Open();
sql_cmd = sql_con.CreateCommand();
sql_cmd.CommandText = txtQuery;
sql_cmd.ExecuteNonQuery();
sql_con.Close();
}

public Form1()
{
InitializeComponent();
}

private void btnRegister_Click(object sender, EventArgs e)
{
string txtSQLQuery = "INSERT INTO users VALUES ('"+tbMail.Text+"', '"+tbNick.Text+"', '"+tbPwd.Text+"')";
ExecuteQuery(txtSQLQuery);
}

private void Form1_Load(object sender, EventArgs e)
{
if (File.Exists("data"))
{
}
else
{
string txtSQLQuery = "CREATE TABLE users (email VARCHAR(64), nickname VARCHAR(16), password VARCHAR(16));";
ExecuteQuery(txtSQLQuery);
}

}
}
}

Povestea merge bine pana la partea cu INSERT INTO, unde zice no such table: users, de ce face asta?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...