473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Grid View Troubles

6
Hi, I’m having trouble with my grid view, I've search around and didnt find any help so I thought I'd post my problem. When the user is signed into my site and clicks button1, the users name is turned into a string and used in a query to display all the information for that user, but unfortunately it doesn’t work. It should output all the CD’s the user has input into the database. Here’s the code I have…

Expand|Select|Wrap|Line Numbers
  1. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim myString As String
  3.          myString = Page.User.Identity.Name.ToString()
  4.  
  5.         Dim DBConn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=""|DataDirectory|\aspnetdb.mdf"";Integrated Security=True;User Instance=True")
  6.  
  7.         Dim DBCmd As New SqlCommand
  8.         Dim DBAdap As New SqlDataAdapter
  9.         Dim DS As New DataSet
  10.         Dim dt As New DataTable
  11.         DBConn.Open()
  12.  
  13.             DBAdap = New SqlDataAdapter("SELECT * FROM Table1 WHERE UserName = " & myString, DBConn)
  14.  
  15.             DBAdap.Fill(dt)
  16.  
  17.             GridView1.DataSource = dt
  18.             GridView1.DataBind()
  19.  
  20.         DBCmd.Dispose()
  21.         DBAdap.Dispose()
  22.         DBConn.Close()
  23.         DBConn = Nothing
  24.     End Sub
  25.  
When I run it this error comes up “SQLExeption was unhandled by usercode” and it also says “Invalid column name 'Rachel'.”. Rachel is actually the user I’m signed into the site and is the value in myString which is fine, but I don’t seem to see what the problem is. Could it be that UserName is set to NVARCHAR in the sql database? Can someone help me out, I’d really like to get this working. Any advice or help would be great.

Thanks,
CaJack
Apr 24 '07 #1
0 971

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: pmud | last post by:
Hi, I need to display columns in a data grid based on 7 different queries. Now I have 32 questions: 1. Is it possble to have 1 single data adapter with 7 queries & 1 data set or do I need to...
12
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
2
by: Jan Mueller | last post by:
Hi all, I don't know whether this is the right group, let me know :-). I tried to open this XML file (with internal DTD) with XMLSpy 2005. I guess some of you also use this tool. ...
2
by: Rhonda | last post by:
Using AccessXP I have lost snap to grid on my system. New or existing databases do not snap to grid for forms and reports in design view. Anyone have an idea on how to get it back?? Thanks. ...
4
by: Filippo Pandiani | last post by:
I have a grid that shows the file list from a folder. On the postback, how do I get a Dataset from this grid? Thanks, Filippo.
0
by: ¿ Mahesh Kumar | last post by:
I have created a XML file as datasource which i 'm binding to a grid view control. During runtime I'm capturing items in XML file and displaying in a GRID VIEW control. but i want to remove or...
1
by: Ed | last post by:
hi everyone, maybe someone can give me a hand here. I am working with vb 2005 and i have a gridview that i am loading data from a recordset. I have the recordset returned from the query and i am...
2
by: Umeshnath | last post by:
Hi, I have placed a grid view inside Atlas panel. On click of a button event, data is populated in the grid view, I want to add scroll bar instead of increasing the size of grid view. I have...
0
by: zafar | last post by:
I don't know what property should be used for hiding colums in Data Grid, whereas in Data Grid View we have DataGridView1.Colums(index).Visible = False , But how can I hide Colums in Data Grid.....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.