Trying To Retrieve Info From Db- Not Sure How To Label This Question
Sep 7, 2004
I have a table that has a column with multiple manufacturer names. Many rows are identical manufacturers. I want to create an asp page that shows only one instance of a particular manufacturer.
Basically if I have 30 entries of Manufacturer 1, 40 entries of Manufacturer 2, etc. I only want to see Manufacturer 1 and Manufacturer 2 once in the display, not as many times as it is listed in the column. Is this an ASP or SQL question?
Basically I know the beginning should look like this:
Code:
SELECT Col1, Col2
FROM dbo.tbl_Myinfo
ORDER BY Col2
But that is about the extent of where I know what to do.
I wanted to create this so I can list the manufacturers that I currently have loaded in my SQL table/ available for more detailed searching.
i wanna know is there a way to retrieve data from the sql database and then instead of putting it in the datagrid, can i put a specific field of data to a textbox?
i mean just a data (for example, a username where the password match the username) in a textbox.
Below is code for inserting data into the database that I know works, so I thought if I replace "Insert" with "Select" I could retrieve a specific row from my database and present it in a label or text box but nothing happened. How can I retrieve a row or rows from a database using vb code and display it in a textbox? I'm using visual web developer 2008 which is similar to 2005. Thank you.
Dim UserDatasource As New SqlDataSourceUserDatasource.ConnectionString = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString1").ToString()
UserDatasource.InsertParameters.Add("username", Context.User.Identity.Name) UserDatasource.InsertParameters.Add("comments", txtSearch.Text)UserDatasource.InsertParameters.Add("points", points) UserDatasource.InsertParameters.Add("ipaddress", Request.UserHostAddress)UserDatasource.InsertParameters.Add("datatimestamp", DateTime.Now()) Dim rowaffected As Integer = 0
Try rowaffected = UserDatasource.Insert()MsgBox("Thanks for the post", MsgBoxStyle.OkOnly, "Post Executed") txtSearch.Text = ""Catch ex As Exception MsgBox("Please sign in or sign up to post comment", MsgBoxStyle.OkOnly, "Login Error") End Try
Table 2 Email ------- EmailId, RxId(duplicates ok), Subject, Message, To, From, Type
I would like the result to be
Result Table ------------ Rx Id, RxDate, Name, Notes(or Subject), Type
Table 1 can be searched by date, or Name or DOB I want the result of this search to go through table 2 and return to me all emails that match thre previous results RxIds
If I do a search for Rxs that were prescribed from 1/1/2005 to 7/1/2005 I would like the resulting table to be RxId RxDate Name Note/Subject Type 99 1/1/2005 Person1 Note1 1 98 3/1/2005 Person1 Note2 1 98 3/1/2005 Person2 S2 2 98 3/1/2005 Person2 S5 2 98 3/1/2005 Person2 S8 2 95 6/1/2005 Person5 Note5 1 95 6/1/2005 Person2 S4 2 95 6/1/2005 Person2 S6 2
I have tried a combination of inner joins and Union with no luck any suggestions
I got a problem using an OLE-DB Source in my data flow task. It is an Informix-Server using the newest OLE DB-Driver provided by IBM. However, when I set up the OLE DB-Source with connection manager and SQl-Query, I get the following warning message:
Warning at {2B334CA3-A792-4BC2-93AA-12FADCF1E696} [OLE DB Source [45]]: Cannot retrieve the column code page info from the OLE DB provider. If the component supports the "DefaultCodePage" property, the code page from that property will be used. Change the value of the property if the current string code page values are incorrect. If the component does not support the property, the code page from the component's locale ID will be used.
Later when I try to execute the package, the destination adapter gets errors like
Error 3 Validation error. Data Flow Task: OLE DB Destination [2985]: Columns "antrag" and "Antrag" cannot convert between unicode and non-unicode string data types. Informix_OLEDB.dtsx 0 0
I guess that SQL Server cannot get the data types from the Source.
I want to be able to see when records have been added to a table. The issue is we have a DTS job scheduled to run every night. The developer who wrote it password protected it and doesn't work here anymore. I want to add a step to this series of DTS jobs and want to run it just prior to his job. Is there a way to see when the records are being added or when this job is being run? Thanks again, you guys are the best.
i have to display some of my SQL data on a webpage, and i don't want to use the gridview and all his "friends". all i want is to display some values out of the sqlDataSource on my webpage.is it possible? and if so, then how can i do it?thanks in advance.
I have a Report that has a document map Label in the Report which I need to remove. However as the report has over 50 text-boxes I am having difficulty locating it. I have had a look at the XML but that does not seem to indicate the offending text box. Any advice would be greatly appreciated.
Hi,Just a little question...Is it possible to link a SqlDataSource to a label without using a repeater or a formview?I just want to select one column from a single row in a single table and sending the value to a label.The code would be something like this :<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" SelectCommand="SELECT name FROM Page WHERE idPage = 1"> <SelectParameters> <asp:Parameter DefaultValue="1" Name="idPage" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> <asp:Label ID="Label1" runat="server" Text='<%# Eval("name") %>'></asp:Label> So, what can I add in the label properties or in the codefile to make this work if it is possible ?Or am I obliged to "hard code" it in c# with an SqlConnection, a SqlCommand and a SqlDataReader ?Thanks in advance...
I am trying to select info from a database (MS-SQL) and show that whit a label. And don’t really get every thing to work. So I am glad for that help I can get.
A SQL Server 2005 stored procedure expects a parameter UserID depending upon which it retrieves the no. of records & OrderIDs corresponding to the UserID from a DB table (note that OrderID & UserID are two of the columns in the DB table). So for e.g. consider a user whose UserID=6 & the DB table has 3 records where UserID=6. In other words, there are 3 OrderID records of the user whose UserID=6, say, OrderID=8, OrderID=17 & OrderID=29. The stored procedure will finally return 2 columns - the OrderCount (which is 3 for UserID=6) & the OrderID (which will be 8, 17 & 29 for UserID=6). This is the stored procedure:ALTER PROCEDURE dbo.OrderCount @UserID intASDECLARE @OrderCount intSET @OrderCount = (SELECT COUNT(OrderID) FROM NETOrders WHERE UserID= @UserID)SELECT @OrderCount AS OrderCount, OrderIDFROMNETOrdersWHEREUserID = @UserIDIn a VB class file, I am invoking the stored procedure in a function named GetOrderCount which returns a SqlDataReader back to the calling ASPX page. I want the ASPX page to display the 3 OrderIDs of UserID=6 in a Label control. Unlike the DataBinding controls like DataList, DataGrid, Repeater controls, the Label control will not automatically loop through the recordset. So I tried to accomplish this using a For....Next loopDim i As IntegerDim sqlReader As SqlDataReaderiUserID = Request.Cookies("UserID").Value'ShopCart is the name of the class in the VB class fileboShopCart = New ShopCartsqlReader = boShopCart.GetOrderCount(iUserID)While (sqlReader.Read) If (sqlReader.GetValue(0) > 1) Then pnlLinks.Visible = True For i = 1 To sqlReader.GetValue(0) lblLinks.Text = sqlReader.GetValue(1)(i) Next i Else pnlLinks.Visible = False End IfEnd WhileBut this generates the following error:No default member found for type 'Integer'.pointing to the linelblLinks.Text = sqlReader.GetValue(1)(i)in the above shown ASPX code. Can someone please correct me & suggest how do I loop through the recordset so that I can display the records in a Label control?
This is my SQLDataSource for my gridview <asp:SQLDataSource ConnectionString="<%$ ConnectionStrings:Pubs %>" id="sqlProducts" Runat="Server" SelectCommand=' "Select * from adressen INNER JOIN Adressoort ON adressen.AD_ID = Adressoort.AD_ID where " & lblsql.Text ' ></asp:SQLDataSource> the label is something like : adressoort.AD_soort = '3' or adressoort.AD_soort = '1' I keep on getting the error sever tag not well formed
Hi all,I would like to do something I thought was simple but I can't seem to figure it out. I would like to bind the Text properties to two labels to the columns in an SqlDataSource, much the same as you can bind a listbox to a SqlDataSource.Is this possible?The reason why I'm trying it this way is because I originally used an OleDB connection and datareader, but it doesn't seem to work on our service providers server (keeps saying that it can't find the database) even though it works on the four other server's I've tried. It definitely connects to the database when I use the SqlDataSource on a listbox control, but it fails when I use the same connection string with the OleDB connection.Is this the best way to go about it, or should I persist with finding the OleDB/datareader (the service provider has been no help at all). Thanks.
Hi all. I have a label on my page and I want to bind it to a field in a table. The catch is that I want to bind it to the last row in the table. I think I can use the custom binding, but I don't know how to bind to the last row. Any Suggestions ? p.s. The page is tied to an SqlDataSource that retrieves the data from the above table. Thanks in advance.
hi, i have this code it gets the records from db i need to add the results of the datareader to a label but label control does not have a datasource property second problem is how to comma separate the results.with array? or what please help i need to show the results like this: record1,record2,record3Dim Conn As New SqlConnection(ConfigurationManager.ConnectionStrings("Conn").ConnectionString) Dim strSQL As StringDim dr As SqlDataReader Dim userID As Integer = Session("cmmLogonUserID") strSQL = "select id,extension from musicExt"Dim cmd As New SqlCommand()cmd = New SqlCommand(strSQL, Conn) Conn.Open() dr = cmd.ExecuteReader()
'txtMediaFormats.Text = dr ??????? ' ddlGenres.DataBind() ???????? Conn.Close()
Hi, I have a sqldatasource which returns the result I want, but I need to assign it to a label or text box. Is there an easy way of doing this? I attempted it using this code: PropertyFriendIDLabel.Text = PropUserIdSqlDataSource Thanks
Here is my code. Basically what I am doing is selecting from the database based on the current user. The ReaderResults.Text label is not showing the info pulled from the database, and the ReaderError.Text label is not showing an error. I also tried putting the ReaderResults.Text label inside the loop and that didnt work. Any suggestions? 'Database ConnectionDim con As New SqlConnection("Data Source = .SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|ASPNETDB.mdf;user instance=true")Dim currentUserID currentUserID = Context.User.Identity.Name.ToString() Label1.Text = currentUserID Dim selectSQL As String selectSQL = "SELECT companyKey FROM Company WHERE UserID = ('" + currentUserID + "')"Dim cmd2 As New SqlCommand(selectSQL, con) Dim reader As SqlDataReaderDim CompanyKey Try con.Open() reader = cmd2.ExecuteReader()Do While reader.Read() CompanyKey = reader("CompanyKey").ToString() Loop reader.Close()Catch err As Exception ReaderError.Text = "Error selecting record." ReaderError.Text &= err.Message ReaderResults.Text = CompanyKey Finally con.Close() End Try
The ReaderResults.Text is not returning a value. I am not sure what is going on because the table and all columns are full, Label1.Text shows the current username of the user loggedon, and no error is showing up in ReaderError.Text. Anyone have any ideas? Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Database ConnectionDim con As New SqlConnection("Data Source = .SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|ASPNETDB.mdf;user instance=true") 'Job1 InfoDim currentUserID currentUserID = Context.User.Identity.Name.ToString() Label1.Text = currentUserID Dim selectSQL1 As String selectSQL1 = "SELECT companyKey FROM Company WHERE UserID = ('" + currentUserID + "')"Dim cmd1 As New SqlCommand(selectSQL1, con) Dim reader As SqlDataReaderDim CompanyKey 'Job1 Select Try con.Open() reader = cmd1.ExecuteReader()Do While reader.Read() CompanyKey = reader("CompanyKey").ToString() Loop reader.Close()Catch err As Exception ReaderError.Text = "Error selecting record." ReaderError.Text &= err.Message ReaderResults.Text = CompanyKey Finally con.Close() End Try
I have a simple column chart where the x axis is a week number, and the y axis is percent of sales. There are four charts on one page, so this chart is very small. There are only two bars on the chart, and I would like to have the value of the y axis, say 7.2%, be displayed on the bar itself. Currently, I can't decipher the exact value of each bar. Does anybody know if, and how, this can be accomplished? Thank you!
I have a long expression that returns the value of my one label. The expression is suppose to figure out if there are three parts to the MailAddress field and return the appriopriate number of fields properly formated. The format I need to get returned from this delimited field looks like
PersonIdNumber
CO Line
Name Here
123 Address Street
City State Zip Country
Each line is followed by a semicolon which I have coded to each be replaced by a newline. The main problem is that sometimes we have a CO Line and sometimes we don't. There will be a delimeter right before the AddressStreet Line even if the CO Line does not exist, so that shouldn't be a problem.
Also, the Name Here line is not returned from my delimited MailAddress field, it is a seperate field. For some reason the label returns an error in the report. I'm assuming it is it is in the code below. If you see something wrong with the expression please let me know.
Am trying to create a mailing label report so that it can pull out the details from the database and gets printed onto the label stickers correctly. However, no matter how i adjust the sizes of the report from the page properties, it's still not printed properly.
I have 7 label stickers on 1 mailing page, so let's say i have 13 records, that will be 2 mailing pages. Each label sticker is about 9cm width by 3.6 cm height. The gap between each label sticker is 0.2 cm
Can anyone advise me on how to go about doing it? By the way, i am using SSRS 2000.
i am once again working with mailing labels. I have designed the report in SQL Server Reporting Services to print in 3 columns with a body size of 2.625" wide by 1.00" high; a rectangle the same size which then contains a list the same size which contains the data fields. I get fairly good results when I print to one printer however, there does seem to be a bit of "creep" on the page. The problem really shows when trying to print to another network printer where when a user prints the report (labels) by the end of the page data is printing outside of the label margins. are there some properties that I'm missing that would prevent this or could this be related to printer settings?
I have a SQL database with 1 column in it.. it is a do not call registry for my office. I want to make a web application so our leads can go on the web and request to be put on the do not call list. problem is, if their number already exists, it gets a violation of primary key... Normal handling for this would be to do a select query based on user input, and if it exists in the database, tell them that, else do the insert query... Problem is, i cant seem to figure out how to bind the result of the select query to a textbox or label so i can compare the results to do that logic. Any ideas? This is in asp .net 2.0. Thanks! -Dan
how can i display the result of an asp:SqlDataSource into a lable control.the sqldatasource returns the count for some thing ie "select count(*) as total from tbl"please help
Hi,I want to run a select query and copy the result to a label. I created a SqlDataSource1, but I don't know how to go ahead.I would like to do something like:string x = SqlDataSource1.SelectCommandPlease, advice!
I'm designing a database that will not be that large (I would be surprised if it ever surpassed 50,000 rows across all tables), but will be accessed quite often, so I am doing my best to optimize its structure, such as doing 3NF, selecting appropriate data types, etc.
I have a few columns that will contain numeric data (such as an invoice number (from an external source) or location ID). However, one of my classes in college was about database design, and we were taught that if you won't be doing mathmatic computation on a field (such as the invoice or location fields I mentioned earlier), then you should use a string literal type (char, varchar, etc.)
Unfortunatly, the professor did not explain much as to why this should be done. From the standpoint of semantic analysis, these types of fields are probably more labels than they are numbers. However, I don't find that very convincing (or even helpful).
In short, my question is that given a column holding numeric data that isn't worked on in a mathematical sense, is it really better to mark it as a string literal than a number? Any articles or studies I can read relating to this?
I would think that comparisons would be faster with int, as well as data storage (though, as mentioned, that's not as big of a concern). Sadly, Google doesn't have many helpful resources. (Lots of stuff on char vs varchar, though.)