Showing posts with label access. Show all posts
Showing posts with label access. Show all posts

Wednesday, March 28, 2012

TableAdapters using values

I have created a data access layer, have a datset with several tables. In VB I would like to access a the value of a particular cell, put that value into a variable. I am unsure how to do this. So far I have,

1Imports DataSet1TableAdapters2~~~~~~34Dim testID = Request("tid")56Dim levelAs Integer = 07Dim testsTableAdapterAs New TestsTableAdapter89level = testsTableAdapter.GetTestsByTestID(testID).Rows(0).Table.Columns(1)10

I know that this is incorrect, however I wish to get the value held in row 1 column 2. Any help would be much appreciated.

Hi,

Based on my understanding, you want to get the value held in particular cell by DataAdapter. If I have misunderstood you, please feel free to tell me, thanks.

 
Dim constrAs String =""'your connection stringDim connectionAs SqlConnection =New SqlConnection(constr)Dim sqlselAs String ="select * from test"Dim sdaAs SqlDataAdapter =New SqlDataAdapter(sqlsel, connection)Dim dsAs DataSet =New DataSet() sda.Fill(ds,"table")Dim levelAs Integer = ds.Tables("table").Rows(1)(2)
 Hope this can help you.

Try this

SqlConnection conn= new SqlConnection("YOUR CONNECTION STRING")
sql = "select * from TableName"
SqlDataAdapter ad = new SqlDataAdapter(sql, conn)
DataSet DS = new DataSet()

ad.Fill(DS,"TableName") // OR ad.Fill(DS.Tables(0))

Dim lvl As Integer
lvl = (int) DS.Table(0).Rows(1)


thanks for replying.

I was hoping to do it without setting a connection string or inputting SQL into the code. I want the dataset in my DAL to take care of this. Is there any way for the tableadapter to populate a new dataSet?


Please refer to this thread below

http://forums.asp.net/p/1187777/2031770.aspx#2031770

This might give you an idea

TableAdaptor Update Access database

I used the wizard in VS2005 to create my connection, dataset, and tableadapt
or
I have a typed dataset named dsUserInfo
I have a tableadaptor named taFillUserInfo
I would like to on the vb side be able to do update the database when a
button is clicked executing the following code.
if me.textbox1.text = "x" then
taFillUserInfo.text1 = me.textbox1
else
some message
End if
What I can't get is how to "call" my tableadaptor taFillUserInfo to get the
column names.Ysgrifennodd Andre:
> I used the wizard in VS2005 to create my connection, dataset, and tableada
ptor
> I have a typed dataset named dsUserInfo
> I have a tableadaptor named taFillUserInfo
> I would like to on the vb side be able to do update the database when a
> button is clicked executing the following code.
> if me.textbox1.text = "x" then
> taFillUserInfo.text1 = me.textbox1
> else
> some message
> End if
> What I can't get is how to "call" my tableadaptor taFillUserInfo to get th
e
> column names.
>
I can't remember if this answers your question directly, but it should help:
http://www.peredur.uklinux.net/TypedDataSets.pdf
This example project (which is really about forms authentication), uses
a Typed DataSet. It definitely shows you how to use the Typed DataSet
using the column names:
http://www.peredur.uklinux.net/Form...ticationSln.zip
Note that the zip file contains a complete .NET solution. I cannot
guarantee that it is virus-free. I think it is; but I can't guarantee
it. So please examine the code and recompile it before running it.
Both the above use C# rather than VB, but I don't think that should give
you too much trouble. It might even persuade you to use C# :)
HTH
Peter

TableAdaptor Update Access database

I used the wizard in VS2005 to create my connection, dataset, and tableadaptor

I have a typed dataset named dsUserInfo
I have a tableadaptor named taFillUserInfo

I would like to on the vb side be able to do update the database when a
button is clicked executing the following code.

if me.textbox1.text = "x" then
taFillUserInfo.text1 = me.textbox1
else
some message
End if

What I can't get is how to "call" my tableadaptor taFillUserInfo to get the
column names.Ysgrifennodd Andre:

Quote:

Originally Posted by

I used the wizard in VS2005 to create my connection, dataset, and tableadaptor
>
I have a typed dataset named dsUserInfo
I have a tableadaptor named taFillUserInfo
>
I would like to on the vb side be able to do update the database when a
button is clicked executing the following code.
>
if me.textbox1.text = "x" then
taFillUserInfo.text1 = me.textbox1
else
some message
End if
>
What I can't get is how to "call" my tableadaptor taFillUserInfo to get the
column names.
>
>


I can't remember if this answers your question directly, but it should help:

http://www.peredur.uklinux.net/TypedDataSets.pdf
This example project (which is really about forms authentication), uses
a Typed DataSet. It definitely shows you how to use the Typed DataSet
using the column names:

http://www.peredur.uklinux.net/Form...ticationSln.zip
Note that the zip file contains a complete .NET solution. I cannot
guarantee that it is virus-free. I think it is; but I can't guarantee
it. So please examine the code and recompile it before running it.

Both the above use C# rather than VB, but I don't think that should give
you too much trouble. It might even persuade you to use C# :)

HTH

Peter

Tuesday, March 13, 2012

Talking between two different web servers

I have two different servers (different ip addresses). They are running IIS. They both have access databases. The first server contains a website.

What is the simplest way to use my website to connect to the other server? My goal is to send information to the access database on the other sever. How can they communicate with one another?

Thanks

Hi,

You can create a web service on the second server. Or you can create a second web site on the second server and receive form data from the first server.


Thanks.

How can I receive data from the second server by receiving form data from the first server? Would I have to set up connection strings specifying both servers? Both servers are located in different regions and not on the same local network. For it to be possible, their IP addresses would have to be unique right? If you know of any on-line references dealing with this subject let me know.

Also these are simple MS Access databases and not MS SQL databases.