Could anyone help me with these;
1. Create a new line in vb 2008 (endl in c++)
2. Steps in updating a database when the database resides into another computer
(for my client/server application)

Thanks averyone, hope you could do something for this! my system is almost done...

Mark, you will have to give us a bit more info here.

What do you mean by -

Create a new line in vb 2008

, a new line of code, a string etc?

What kind of database are you using, Sql, MySql, Access etc?

In the mean while, have a look at the following link to getting your app connected to the database -

http://www.connectionstrings.com/, choose your database and go through the connection string that will suite you.

Ok, I'm sorry for the insufficient information. Well, new line whose equivalent in C++ is "endl". When this code is executed, the following string will be printed to the next line of the screen during run-time.
And then my database is MS Access 2007 (compatible with vb 2008)

I hope that was sufficient already,
Thanks!
Please, be an angel to me!

Use vbCrLf - new line (line feed character).

Alright! That's what I was so looking forward. CRLF! How about for my database?

Alright! That's what I was so looking forward. CRLF! How about for my database?

Dim sql = "update tableName set colName1=@p2 where colName2=@p1"
        cmd.CommandText = sql
        cmd.Connection = cn
        cmd.Parameters.AddWithValue("@p2", "Hello" & vbCrLf & "World")
        cmd.Parameters.AddWithValue("@p1", my_id)

I can't figure this out. What's in the code ADATAPOST?

I can't figure this out. What's in the code ADATAPOST?

I guess you will have to put in a bit more effort and try it on your own. Read the MSDN documentation or books related to the Database API and do some experimentation.

There are several ways to connect to a database on another computer.
If the database is on a Microsoft SQL Server, then you have the System.Data.SqlClient namespace.
If the database is an Access database, then you have the System.Data.OleDb namespace.

So, assuming the the database is an MS SQL Server then this is one way to connect to it.

Imports System.Data.SqlClient

Private Sub UpdateDatabase()
   Dim con As New SqlConnection("Data Source=computer2; Initial Catalog=thedatabase; User ID=billybob; Password=hamburger;")
   Dim com As SqlCommand = Nothing

   Try
      con.Open()
      com = New SqlCommand("UPDATE table SET col2=@p2 WHERE col1=@p1", con)
      com.Parameters.AddWithValue("@p1", 365)
      com.Parameters.AddWithValue("@p2", "Hello World")
      com.ExecuteNonQuery()
      con.Close()
   Catch ex As Exception
      If con.State = ConnectionState.Open Then
         con.Close()
      End If
   End Try
End Sub

For an Access database, the equivalent would be this:

Imports System.Data.OleDb

Private Sub UpdateDatabase()
   'MS Access 97-2003
   Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\computer2\sharedfolder\mydatabase.mdb;User Id=admin;Password=;")
   'MS Access 2007
   Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\computer2\sharedfolder\myAccess2007file.accdb;Persist Security Info=False;")

   Dim com As OleDbCommand = Nothing

   Try
      con.Open()
      com = New OleDbCommand("UPDATE table SET col2=@p2 WHERE col1=@p1", con)
      com.Parameters.AddWithValue("@p1", 365)
      com.Parameters.AddWithValue("@p2", "Hello World")
      com.ExecuteNonQuery()
      con.Close()
   Catch ex As Exception
      If con.State = ConnectionState.Open Then
         con.Close()
      End If
   End Try
End Sub
commented: :) +10

Thank you so much guys, well, at least this community has helped me in my thesis. Special thanks to adatapost and oxiegen whoever you are. until next time!

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.