Hey can some good person who knows C# please send a PM me, I need your help. I will send you my skype.
I really need help, thank you
6 replies to this topic
#1
Posted 04 February 2011 - 07:51 AM
|
|
|
#2
Posted 04 February 2011 - 12:10 PM
Maybe you could just post your problem here, so everyone can learn from it. :)
~ Committed.
~ Committed.
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
#3
Posted 06 February 2011 - 01:31 AM
maybe you could post all your problems here to have some great answers from experts. :cool:
#4
Posted 07 February 2011 - 12:23 PM
hy people...i'm new here...i'm from croatia so if i have english mistakes don't mather...i have a next problem...i have application from which i have to connect to my database...i made database in c#...and i don't know how to connect it...i need to save information into table from user input on my form by clicking button...after that i need to create some form from which i can see all informations in table and to have a button to print that table...
here is my code for saving informations but it doesn't work
here is my code for saving informations but it doesn't work
private void button1_Click_2(object sender, EventArgs e)
{
using (SqlConnection connection = new SqlConnection())
{
string ConnectionString = "Data Source=localhost;Initial Catalog=ETSDTB;Integrated Security=SSPI;";
SqlConnection myConnection = "Trusted_Connection=yes;" +
"database=ETSDTB;" +
"connection timeout=30";
myConnection.Open();
try
{
myConnection.Open();
}
catch (Exception)
{
MessageBox.Show(ToString());
}
SqlParameter Ime = new SqlParameter("@Ime", SqlDbType.VarChar, 11);
SqlCommand myCommand = new SqlCommand("INSERT into Tehničar_za_računalstvo (Ime, Prezime, Dan_Rođenja, Mjesec_Rođenja, Godina_Rođenja, Učeni_Jezik, Religijski_Predmet, Dodatni_Bodovi, Broj_Dod.Bodova, Matematika_7, Matematika_8, Hrvatski_7, Hrvatski_8, Strani_Jezik_7, Strani_Jezik_8, Fizika_7, Fizika_8, Teh._Kultura_7, Teh._Kultura_8, Prosjek_7, Ponavljač)"+
"VALUES (@textBox22_TextChanged,@textBox12_TextChanged_2,@textBox13_TextChanged_1,@textBox19_TextChanged_2,@textBox20_TextChanged_1,@textBox11_TextChanged_2,@textBox3_TextChanged_1,@textBox16_TextChanged_2,@textBox18_TextChanged_2,@textBox17_TextChanged_2,@textBox4_TextChanged_1,@textBox6_TextChanged_1,@textBox5_TextChanged_1,@textBox8_TextChanged_1,@textBox7_TextChanged_1,@textBox10_TextChanged_1,@textBox9_TextChanged_1,@textBox15_TextChanged_2,@textBox14_TextChanged_2,@textBox2_TextChanged_1,@textBox23_TextChanged", myConnection);
}
}
i hope someone can help me with this
#5
Posted 07 February 2011 - 01:01 PM
@Tonchi I dont really know much about DB work, but if you create a new thread you more likely to get help.
~ Committed. :)
~ Committed. :)
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
#6
Posted 10 February 2011 - 01:50 PM
Your code most likely doesn't work because you have simply declared your variable but have never used it?? I can't be sure without testing the code, but whenever I work with mysl and c# it looks like:
SqlCommand myCommand = new SqlCommand("INSERT into Tehničar_za_računalstvo (Ime, Prezime, Dan_Rođenja, Mjesec_Rođenja, Godina_Rođenja, Učeni_Jezik, Religijski_Predmet, Dodatni_Bodovi, Broj_Dod.Bodova, Matematika_7, Matematika_8, Hrvatski_7, Hrvatski_8, Strani_Jezik_7, Strani_Jezik_8, Fizika_7, Fizika_8, Teh._Kultura_7, Teh._Kultura_8, Prosjek_7, Ponavljač)"+
"VALUES (@textBox22_TextChanged,@textBox12_TextChanged_2,@textBox13_TextChanged_1,@textBox19_TextChanged_2,@textBox20_TextChanged_1,@textBox11_TextChanged_2,@textBox3_TextChanged_1,@textBox16_TextChanged_2,@textBox18_TextChanged_2,@textBox17_TextChanged_2,@textBox4_TextChanged_1,@textBox6_TextChanged_1,@textBox5_TextChanged_1,@textBox8_TextChanged_1,@textBox7_TextChanged_1,@textBox10_TextChanged_1,@textBox9_TextChanged_1,@textBox15_TextChanged_2,@textBox14_TextChanged_2,@textBox2_TextChanged_1,@textBox23_TextChanged", myConnection);
myCommand.ExecuteScalar();
///////////////////////////////////////////////
You can also try something like this - this will most likely work, since this is how i do things with a database:
// beginning of the file/program:
using System.Data;
using System.Data.Odbc;
// Inside your class
private void button1_Click_2(object sender, EventArgs e)
{
string ConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
"SERVER=localhost;" +
"DATABASE=orion;" +
"UID=user;" +
"PASSWORD=password;" +
"OPTION=3";
OdbcConnection Connection = new OdbcConnection(ConString);
Connection.Open();
OdbcCommand wq = new OdbcCommand("insert into amonra (iger,x,tesiento,logarythm) values(NULL,'"+bitches+"','"+v+"',34) ", Connection);
wq.ExecuteScalar();
Connection.Close();
}
///////////////
To summarize: Use executescalar or executenonquery - you can by the way easily convert executescalar to other useful data types like this:
string niga = johny.executescalar().ToString()
or something like this...
SqlCommand myCommand = new SqlCommand("INSERT into Tehničar_za_računalstvo (Ime, Prezime, Dan_Rođenja, Mjesec_Rođenja, Godina_Rođenja, Učeni_Jezik, Religijski_Predmet, Dodatni_Bodovi, Broj_Dod.Bodova, Matematika_7, Matematika_8, Hrvatski_7, Hrvatski_8, Strani_Jezik_7, Strani_Jezik_8, Fizika_7, Fizika_8, Teh._Kultura_7, Teh._Kultura_8, Prosjek_7, Ponavljač)"+
"VALUES (@textBox22_TextChanged,@textBox12_TextChanged_2,@textBox13_TextChanged_1,@textBox19_TextChanged_2,@textBox20_TextChanged_1,@textBox11_TextChanged_2,@textBox3_TextChanged_1,@textBox16_TextChanged_2,@textBox18_TextChanged_2,@textBox17_TextChanged_2,@textBox4_TextChanged_1,@textBox6_TextChanged_1,@textBox5_TextChanged_1,@textBox8_TextChanged_1,@textBox7_TextChanged_1,@textBox10_TextChanged_1,@textBox9_TextChanged_1,@textBox15_TextChanged_2,@textBox14_TextChanged_2,@textBox2_TextChanged_1,@textBox23_TextChanged", myConnection);
myCommand.ExecuteScalar();
///////////////////////////////////////////////
You can also try something like this - this will most likely work, since this is how i do things with a database:
// beginning of the file/program:
using System.Data;
using System.Data.Odbc;
// Inside your class
private void button1_Click_2(object sender, EventArgs e)
{
string ConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
"SERVER=localhost;" +
"DATABASE=orion;" +
"UID=user;" +
"PASSWORD=password;" +
"OPTION=3";
OdbcConnection Connection = new OdbcConnection(ConString);
Connection.Open();
OdbcCommand wq = new OdbcCommand("insert into amonra (iger,x,tesiento,logarythm) values(NULL,'"+bitches+"','"+v+"',34) ", Connection);
wq.ExecuteScalar();
Connection.Close();
}
///////////////
To summarize: Use executescalar or executenonquery - you can by the way easily convert executescalar to other useful data types like this:
string niga = johny.executescalar().ToString()
or something like this...
#7
Posted 10 February 2011 - 02:42 PM
Hey, quantus! Thanks for trying to help Tonchi, he created a new thread about his question here. http://forum.codecal...c-database.html
You could post you answer there, or see if he has already got it fixed. :)
Also please use code tags like this: [CODE*]Your Code Here[/CODE*] just remove the '*'.
Happy C0ding ~ Committed. :)
You could post you answer there, or see if he has already got it fixed. :)
Also please use code tags like this: [CODE*]Your Code Here[/CODE*] just remove the '*'.
Happy C0ding ~ Committed. :)
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









