User-1819590134 posted
How do <g class="gr_ gr_22 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="22" data-gr-id="22">i</g> connect this SQL statement to a <g class="gr_ gr_19 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling
ins-del multiReplace" id="19" data-gr-id="19">gridview</g>? My database is Microsoft Access.
Select Posts.[Post_Value], Posts.[Date_Time] FROM
Posts WHERE posts.[user_ID] = '" & Session("user_id") & "'
My database connection as a string is this:
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & Server.MapPath("database/Database.mdb")
I know <g class="gr_ gr_31 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="31" data-gr-id="31">i</g> have to open the connection to the database, but what <g class="gr_ gr_32 gr-alert gr_tiny gr_spell gr_inline_cards
gr_run_anim ContextualSpelling multiReplace" id="32" data-gr-id="32">i</g> cant figure out is how to fill the <g class="gr_ gr_23 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" id="23" data-gr-id="23">gridview</g> with the data including
the session variable? I also want this to happen on page load.
I am doing this in windows visual studio, so if you know what <g class="gr_ gr_24 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="24" data-gr-id="24">i</g> need to do on the <g class="gr_ gr_18 gr-alert gr_spell
gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="18" data-gr-id="18">html</g> side <g class="gr_ gr_17 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" id="17" data-gr-id="17">aswell</g> that would be a huge
help!
This is as far as <g class="gr_ gr_25 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="25" data-gr-id="25">i</g> have got with my code, but <g class="gr_ gr_26 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim
ContextualSpelling multiReplace" id="26" data-gr-id="26">i</g> know its rubbish and may not be anywhere near what <g class="gr_ gr_27 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="27" data-gr-id="27">i</g> need.
Private Sub Page_Load1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
& Server.MapPath("database/Database.mdb")
Dim strSQL As String = "Select Posts.[Post_Value], Posts.[Date_Time]
FROM Posts WHERE posts.[user_ID] = '" & Session("user_id") & "'"
Dim connection As New OleDbConnection(connectionString)
connection.CreateCommand()
Dim oledb As OleDbDataReader(connection)
Dim dataadapter As New OleDbDataAdapter(strSQL, connection)
Dim ds As New DataSet()
connection.Open()
dataadapter.Fill(ds, "posts")
connection.Close()
GridView1.DataSource = ds
GridView1.DataMember = "posts"
GridView1.DataBind()
End Sub
In case <g class="gr_ gr_20 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="20" data-gr-id="20">i</g> haven't been clear, what <g class="gr_ gr_21 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling
multiReplace" id="21" data-gr-id="21">i</g> would like to have at the end of this is: - at page load, a <g class="gr_ gr_16 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" id="16" data-gr-id="16">gridview</g> will appear with all the posts
from the user that is signed in to the session.
Honestly, any pointers would be hugely appreciated!