Hello.

I have a SQL database called bd with a table called dados.
I want to get one row from it.

Web.config

<add connectionString="Data Source=(local);Initial Catalog=bd;Integrated Security=True" name="bd" providerName="System.Data.SqlClient"/>

variable declarations

Dim DS As New bd
Dim a1row As bd.dadosRow

this code in the method won't return anything.
In fact it throws a "object not set to an instance of an object" error.

a1row = DS.dados.FindBycode(5440987) 

but if I perform a query I get the values: <img alt="snapshot" src="https://www.flickr.com/photos/29661370@N04/21923636492/"/>

Where did I go wrong?
Thanks

Recommended Answers

All 3 Replies

From my opinion you do not write the connection string properly.
Please follow this site.

thanks Shark_1 but the error was on the other line of code I should have posted and didn't
dadosTA.Fill(DS.dados)

I don't know how it was but now that it is like this it works

Hi nosfa, are you trying to view your data in a listview table or in textboxes?
You may use queries attached on your searchbox like:

Dim sql = "SELECT UName,Password FROM [databaseName].[dbo].[tableName] WHERE UName = '" & TextBox1.Text & "' AND Password = '" & TextBox2.Text & "'"
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.