hi guys. its been a long time but sincerely, am happy to be back. now i've got a problem on my mind and that is; am trying to develop a database application but i want it to be a console application. the major issue is that i dont know how to go about connecting vb.net console application to sql server or if its possible at all, but am sure its possible in this world of ours....love you all.

it should follow the same concept.

you make Connection to the DB
and send it String commands

MyConnetion.Open()
Dim SqlDataReader Sdr1 = new SqlCommand("Select A, B, C, D FROM XYZ",MyConnetion).ExecuteReader()
While(Sdr1.Read())
{
   Console.WriteLine(Sdr1.GetInt32(0)) 'Assuming A is of type int in the table
   Console.WriteLine(Sdr1.GetString(1)) 'Assuming B is of type String in the table
   Console.WriteLine(Sdr1.GetBoolean(2)) 'Assuming C is of type Bool in the table
}
MyConnetion.Close()

I assume You understand why I use 0,1,2. If not then that is how you called them in the Select statement.

For Update just do

MyConnection.Open()
new SqlCommand("UPDATE XYZ SET A = 7",MyConnection).ExecuteNonQuery()
MyConnection.Close()

For Insert

MyConnection.Open()
new SqlCommand("INSERT INTO XYZ (A,B,C) VALUES (7,'Hello World','True')",MyConnection).ExecuteNonQuery()
MyConnection.Close()

I assume you get the gist of it.

Please mark as solved if solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.