Showing posts with label database. Show all posts
Showing posts with label database. Show all posts

Saturday, March 31, 2012

Table structure from database.

Hi,

Is it possible to retrieve in C# the table structure (primary key, type of data, ...) ?

Thanks a lot.

Sébfrom what database?
from sql server 2000 for example ...
From sql server sir :)
I am not sure that my suggests will solve your problems,
I think that you should write a Sql statement as follow:

ALTER DATABASE database
{ ADD FILE < filespec > [ ,...n ] [ TO FILEGROUP filegroup_name ]
| ADD LOG FILE < filespec > [ ,...n ]
| REMOVE FILE logical_file_name
| ADD FILEGROUP filegroup_name
| REMOVE FILEGROUP filegroup_name
| MODIFY FILE < filespec >
| MODIFY NAME = new_dbname
| MODIFY FILEGROUP filegroup_name {filegroup_property | NAME = new_filegroup_name }
| SET < optionspec > [ ,...n ] [ WITH < termination > ]
| COLLATE < collation_name >
}

SqlClient.ExcuteNonQuery(......);
SQL server 2000 why ?

Thanks

Séb
I'm interested in the structure of Access and SQL databases

TableAdapter Configuration Wizard

Hey

I am trying to get some practice on VS 2005 TableAdapter Configuration
Wizard. I wrote a Database project and include a couple of stored procedures
one of which was an insert procedure. The insert procedure obviously accepts
a few parameters (the values to insert).
I have a problem creating the connection in the TableAdapter Configuration
Wizard for the insert procedure. Basically I cannot map the parameters to the
database table columns where the value was to be inserted.
Can someone please point in the direction of a good tutorial that
demonstreates the creation and use of the TableAdapter Configuration Wizard.
I read something in 15seconds.com: http://www.15seconds.com/issue/050728.htm.
So if you have something other than this, It'd be deeply appreciated.

Thanks
HectorHi Hector:

Here are a couple to look at:

http://weblogs.asp.net/scottgu/arch.../15/435498.aspx
http://msdn.microsoft.com/vbasic/de...bleadapters.asp

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Sat, 4 Feb 2006 18:34:27 -0800, "hecsan07" <hecsan07@.hotmail.com>
wrote:

>Hey
>I am trying to get some practice on VS 2005 TableAdapter Configuration
>Wizard. I wrote a Database project and include a couple of stored procedures
>one of which was an insert procedure. The insert procedure obviously accepts
>a few parameters (the values to insert).
>I have a problem creating the connection in the TableAdapter Configuration
>Wizard for the insert procedure. Basically I cannot map the parameters to the
>database table columns where the value was to be inserted.
>Can someone please point in the direction of a good tutorial that
>demonstreates the creation and use of the TableAdapter Configuration Wizard.
>I read something in 15seconds.com: http://www.15seconds.com/issue/050728.htm.
>So if you have something other than this, It'd be deeply appreciated.
>Thanks
>Hector

TableAdapter Configuration Wizard

Hey
I am trying to get some practice on VS 2005 TableAdapter Configuration
Wizard. I wrote a Database project and include a couple of stored procedures
one of which was an insert procedure. The insert procedure obviously accepts
a few parameters (the values to insert).
I have a problem creating the connection in the TableAdapter Configuration
Wizard for the insert procedure. Basically I cannot map the parameters to th
e
database table columns where the value was to be inserted.
Can someone please point in the direction of a good tutorial that
demonstreates the creation and use of the TableAdapter Configuration Wizard.
I read something in 15seconds.com: [url]http://www.15seconds.com/issue/050728.htm.[/url
]
So if you have something other than this, It'd be deeply appreciated.
Thanks
HectorHi Hector:
Here are a couple to look at:
http://weblogs.asp.net/scottgu/arch.../15/435498.aspx
http://msdn.microsoft.com/vbasic/de...
eadapters.asp
Scott
http://www.OdeToCode.com/blogs/scott/
On Sat, 4 Feb 2006 18:34:27 -0800, "hecsan07" <hecsan07@.hotmail.com>
wrote:

>Hey
>I am trying to get some practice on VS 2005 TableAdapter Configuration
>Wizard. I wrote a Database project and include a couple of stored procedure
s
>one of which was an insert procedure. The insert procedure obviously accept
s
>a few parameters (the values to insert).
>I have a problem creating the connection in the TableAdapter Configuration
>Wizard for the insert procedure. Basically I cannot map the parameters to t
he
>database table columns where the value was to be inserted.
>Can someone please point in the direction of a good tutorial that
>demonstreates the creation and use of the TableAdapter Configuration Wizard
.
>I read something in 15seconds.com: [url]http://www.15seconds.com/issue/050728.htm.[/ur
l]
>So if you have something other than this, It'd be deeply appreciated.
>Thanks
>Hector

Wednesday, March 28, 2012

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

tables and data

trying to populate a table with data from a mssql database, not quite sure
where to start
using asp.net and codebehind - cant seem to find any examples anywhere!Luna,

Check out: www.datagridgirl.com

She's placed many samples on her site.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche

"luna" <luna@.themoon.com> wrote in message
news:7hqYb.542$AQ4.336311@.newsfep2-win.server.ntli.net...
> trying to populate a table with data from a mssql database, not quite sure
> where to start
> using asp.net and codebehind - cant seem to find any examples anywhere!
Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"luna" <luna@.themoon.com> wrote in message
news:7hqYb.542$AQ4.336311@.newsfep2-win.server.ntli.net...
> trying to populate a table with data from a mssql database, not quite sure
> where to start
> using asp.net and codebehind - cant seem to find any examples anywhere!

Saturday, March 24, 2012

Tagging in .NET

I'm wondering if anyone could help me in figuring out the architecture / database tables needed to implement tagging into my website. Users would be tagging their RSS feeds.

Are there any good articles that explain the architecture and tables necessart to implement this?

Thanks in advance.could you explain what you mean by "tagging"?

"implement tagging into my website"

"tagging their RSS feeds."

Whats this "tagging" ?


lol.. jinx Curt... i had my reply window open and stepped away for a bit before i finished my post
Thanks for your reply...

I thought that "tagging" is a fairly well know functionality in the internet world today. I guess I am wrong. Please let me explain...

Flickr.com - allows you to associate words to a photo, or...tag the photo with a descriptive word
http://del.icio.us/ - allows you to "tag" a link with a descriptive word or words.

In my case, I have RSS feeds that I would like to allow the users to "tag" or to associate a descriptive word or words to a feed.

Here is a great article that explains it in more detail. What Im looking to learn and implement is the architecture and datbase tables necessary to incorporate this into my website.

http://freshtakes.typepad.com/znetlady/2005/07/tagging_what_is.html

Thanks again.

So in short:

You are asking "why am I making this more complex than adding a simple 'description' column to a database table" ?

I seriously don't see all the confusing and over-thinking of adding one extra field onto your data table(s) for your users to add/edit/search-on

Thursday, March 22, 2012

Taking out Quotation marks in text.

Hi

How can I take Quotation marks ( " ' ) out of a variable before I post it to a database.

The database return errors if I dont take it out.

ThanksUse the SqlParameter of OleDbParameter classes, and the database will not 'give errors'.
A single quote must be replaced by 2x single quote, when used in a query. This is the cause of the errors.
Check this post...

http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=317174

good luck sir
Thanks that helped a lot
u can use..

dim str as string
str = Replace(the_text, " ' ", "**")

taking text from a drop down list and want to insert into a database


<%@dotnet.itags.org. Page Language="VB" Debug="true" %>
<%@dotnet.itags.org. import Namespace="System.Data" %>
<%@dotnet.itags.org. import Namespace="System.Data.OleDb" %>
<script runat="server"
dim Conn as new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\admin\Desktop\Reminder\dbReminder.mdb")

Sub btnSet_Click(obj as Object, e as EventArgs)

dim objTrans as OleDbTransaction
dim objCmd as OleDbcommand = new OleDbcommand ("INSERT INTO tblReminder (mobile, station, reminder, time) VALUES (@dotnet.itags.org.MOBILE, @dotnet.itags.org.STATION, @dotnet.itags.org.REMINDER, @dotnet.itags.org.TIME)", Conn)
dim objParam as OleDbParameter

objParam = objCmd.Parameters.Add("@dotnet.itags.org.MOBILE", oleDbType.char)
objParam.Direction = ParameterDirection.Input
objParam.Value = lblUser.Text

objParam = objCmd.Parameters.Add("@dotnet.itags.org.STATION", oleDbType.char)
objParam.Direction = ParameterDirection.Input
objParam.Value = lblStation.Text

objParam = objCmd.Parameters.Add("@dotnet.itags.org.REMINDER", oleDbType.Char)
objParam.Direction = ParameterDirection.Input
objParam.Value = DDLFields.SelectedItem.Text

objParam = objCmd.Parameters.Add("@dotnet.itags.org.TIME", oleDbType.char)
objParam.Direction = ParameterDirection.Input
objParam.Value = tbTime.Text

Conn.Open()

objTrans = Conn.BeginTransaction()
objCmd.Transaction = objTrans

try
objCmd.executeNonQuery
objTrans.commit()
catch ex as OleDbException
objTrans.RollBack()
lblError.Text = "Error inserting reminder into database"
end try

objcmd.Connection.Close()
End sub

Private Sub Page_Load(sender As Object, e As System.EventArgs)
If Not Page.IsPostBack Then

dim Conn as new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\admin\Desktop\Reminder\dbReminder.mdb")
dim objTrans as OleDbTransaction
dim objCmd as OleDbcommand = New OleDbCommand("SELECT time + ' ' + programme as fieldone FROM tblRTE ", Conn)
Conn.Open()

DDLFields.DataSource = objCmd.ExecuteReader()

DDLFields.DataTextField = "fieldone"
DDLFields.DataValueField = "fieldone"
DDLFields.DataBind()

Conn.Close()
End If

If Not Request.Cookies("rm_user") Is Nothing Then
lblUser.Text = Request.Cookies("rm_user").Value
end if
End Sub

</script>

This is the code im using to take the information from the form and enter it into the database.
But it displays my error message every time...
Is it correct?
The part im not sure about is this:

objParam = objCmd.Parameters.Add("@dotnet.itags.org.REMINDER", oleDbType.Char)
objParam.Direction = ParameterDirection.Input
objParam.Value = DDLFields.SelectedItem.Text

Is this the correct way of taking the selected items text from the ddl?

Thanks.Your code looks good, however your SQL looks dodgy. Thisthread in the DevShed forum should help.
I do somthing similar on a page. I think your problem is that the code for the DDL is in the on postback block. When the page is posted back ( user chose something and clicked button to do save) the ddl is not populated.
Try taking the DDL code out of the is postback IF block...


Private Sub Page_Load(sender As Object, e As System.EventArgs)

If Not Page.IsPostBack Then
End If

dim Conn as new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\admin\Desktop\Reminder\dbReminder.mdb")

dim objTrans as OleDbTransaction

dim objCmd as OleDbcommand = New OleDbCommand("SELECT time + ' ' + programme as fieldone FROM tblRTE ", Conn)

Conn.Open()

DDLFields.DataSource = objCmd.ExecuteReader()

DDLFields.DataTextField = "fieldone"

DDLFields.DataValueField = "fieldone"

DDLFields.DataBind()

Conn.Close()

If Not Request.Cookies("rm_user") Is Nothing Then

lblUser.Text = Request.Cookies("rm_user").Value

end if

End Sub

also, I don't think you need the transaction stuff. Transactions are used for multiple DB actions. not a single action. The try block should suffice. If the single DB action fails ( your insert) there are no other actions to rollback.
Hope that helps
> I think your problem is that the code for the DDL is in the on postback block. When the
> page is posted back ( user chose something and clicked button to do save) the ddl is not
> populated. Try taking the DDL code out of the is postback IF block...

This is not the problem. The DDL is repopulated via ViewState on PostBack.

I do agree about the Transaction.

One thing that would help solve this is for emmettd to post the error message.
I talking about the error message in my code.

its "Error inserting reminder into database"

its in the code, in the btnSet_click, near the end.
change this line and let us know what you get

lblError.Text =ex.tostring()

Taking your database driven aspx website online.

I have created an ecommerce site using aspx and sql on my local machineat home. And it's now time to take it online and put it on ourserver. Although this is the first site ive ever created usingaspx and sql server. Does anyone know any good tutorials or FAQor anything that would assist me in getting this online... It's all newto me so any help would be greatly appreciated.
Thanx
you need a hoster that supports Asp.Net AND SQL Server.
they will have specifics on how to connect to the the SQL server
You will upload all the .aspx files ( and the directories ) and then upload your .dll's to the "bin" directory
you need to tell some hosters that you are running a .Net site so that they can make your directory an application
HTH


Hello,
What you need now is to find a host then to deploy your application. Let me help you in that
1) one you have hoster, you can access your site using FTP
2) After login to FTP upload your aspx pages to wwwroot of the server
3) Upload the /bin folder to the server also to be like that wwwroot/bin
4) You should access the MSSQL and create database in a control panelthat the hoster will give you the information on how to log in and use
Finally, if u need a great host, i can recommendserverdivision.com, they are oen of the best in .NET technology
HTH
regards

Tuesday, March 13, 2012

Targeting a database path that is outside of the current project?

Well, good thing that the forum stated "No question too simple" because I'm sure this is uber basic...Embarrassed

I have a working Default.aspx page that accesses a database (hsDatabase.mdf) within the App_Data folder. Just the basic ASP website structure automatically made by Visual Web Developer 2005 Express Edition.

The page works fine on the local computer.

The problem is, when I put it up on my server on the web, the server requires all databases to be put in a specific "database" folder which is up a level from the html folder where I put my ASP and HTML files. That is, it's outside of the project folder.

And try as I might, I can't seem to get the Default.aspx page to connect with database when it's not residing in a folder called "App_Data" which is at the same level as the ASP file.

I assume that the key lies in how I write the connectionstring in the web.config file?

This is the connectionstring that works on my computer:
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\hsDatabase.mdf;Integrated Security=True;User Instance=True"

But instead of|DataDirectory|\hsDatabase.mdf, I wish I could just put write a hardcoded address like www.mySite.com/database/hsDatabase.mdf.
Or at least a relative path that worked like../../database/hsDatabase.mdf

How can I connect to a database that's outside of my project folder, or anywhere on the web for that matter?


Thanks everyone!


Hopefully this helps -

Imports System.Data.SqlClientImports System.IOImports System.Web.ConfigurationPartialClass DefaultInherits System.Web.UI.PageProtected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadDim bldrAs New SqlConnectionStringBuilder(WebConfigurationManager.ConnectionStrings("connectionStringName").ConnectionString) bldr.AttachDBFilename = Path.GetFullPath("/otherDir/hsDatabase.mdf")' output modified connection string Response.Write(bldr.ConnectionString &"<hr/>")End SubEnd Class

Well, that's a bit more complicated that I thought it would be! Definitely a change from the old ASP style of doing it.

The outputted modified connection string (bldr.ConnectionString),should I be putting that result into my Default.aspx page or my web.config page? And how do I pass that variable from this .aspx.vb page into the correct page?

BTW... the connection code for the Default.aspx page is: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

while the web.config page is: <connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\hsDatabase.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

Thank you so much again!


Hi robchis,

My suggestion could be wrong,so please correct me if you find any mistakes within my suggestion.Based on my understanding and experience,I think of course you can access the database which is outside of your website root directory. I used to access a sql database which is hosted by another server machine from my website and it works fine. The point is, make sure that the data server has sql-server serverside installed with service correctlly configured and started, then within you website, you can click the "configure Data Source" from you sqldatasource control and input the right sql-server server name and choose the right database.After that you will be able to access the database in your site.

For more and detailed information, please refer to:

http://msdn2.microsoft.com/en-us/library/ms178361.aspx

http://dotnetjunkies.com/QuickStartv20/aspnet/doc/data/databases.aspx