1

has anyone know how to insert some data on SQL Server database?? i've tried this code, but it not works for me.. here's the code:

    Dim constring As String = "Data source=.\sqlexpress;attachDbFilename=|DataDirectory|\Database1.mdf;integrated security=true;connect timeout=30;user instance=true"
    Dim connection As SqlConnection = New SqlConnection(constring)
    Dim query As SqlCommand

        Dim s As String

        connection.Open()

        s = "insert into login values(@un,@pass)"
        query = New SqlCommand(s, connection)
        query.Parameters.AddWithValue("@un", "111")
        query.Parameters.AddWithValue("@pass", "222")

        query.ExecuteNonQuery()

        connection.Close()
5
  • How does it not work? Do you get an error? Wher does the error happen? What is the state of the relevant objects at the time? Commented Nov 9, 2011 at 2:28
  • What's the problem here? What's the error? Commented Nov 9, 2011 at 2:29
  • @David: it has no error, but the database is still empty.. Commented Nov 9, 2011 at 2:31
  • @LarsTech: still can't insert the data on database and the database is still empty.. :( Commented Nov 9, 2011 at 2:32
  • When you debug into the code,mod these statements get executed? Do they have the values you expect? If you profile the database, does the query get executed? If you copy the query from the profiler and execute it manually, what happens? Commented Nov 9, 2011 at 11:06

1 Answer 1

1

Your syntax to create a login is incorrect. You are looking for:

CREATE LOGIN <loginName>
WITH PASSWORD = 'YourPassword'

More information about Create Login can be found on MSDN

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.