Showing posts with label aspnet. Show all posts
Showing posts with label aspnet. Show all posts

Wednesday, March 28, 2012

how to connect with sqlexpress2005 & asp.net for update insert delete codings

I want to know about the how to connect with asp.net 2005 and sqlexpress through codings using parameters

import System.Data.SqlClient;

related update delete insert codings ...

How to know about the make the new connection with different databases sqlserver, oracle mysql...

Hi

Have you had a lookhttp://quickstarts.asp.net/QuickStartv20/default.aspx andhttp://www.asp.net/learn/data-access/.

Work through these samples.. They explain how to access databases using declarative coding (sqldatasource and the likes) and coe behind coding.

Hope that helps.

VJ

How to connect to SQL Server with ASP.NET

Hi
I need help to connect to SQL server, i got Microsoft Visual Web Developer 2005 Express and SQL Server Management Studio Express
With SQL Server Management Studio Express i can make databases and create tables but i dunno how to connect via asp.net
Anyone could give me a helping hand?
Thanks for the help
- Gucchi

Hi
Following is the sample create_connection method that works for me.Hope this helps you.
ALL THE BEST
Chickoo
Sub create_Conn()

Dim oConnectionAs SqlConnection

Dim DAAs SqlDataAdapter

Dim DSAsNew DataSet

Dim sSQLAsString

Dim sConnAs SqlConnection =New SqlConnection("workstation id=<xxx>;packet size=4096;integrated security=SSPI;data source=<xxx >;persist security info=False;initial catalog=<Database Name>;Trusted_Connection=Yes")

sSQL = " SELECT * FROM MyDatabase"

DA =New SqlDataAdapter(sqlstr, sConn)

DA.Fill(DS, "MyTable")

MyGrid.DataSource = DS

MyGrid.DataBind()

sConn.Close()

EndSub

sql

How to connect to sql server on another machine through asp.net

Hi All,

I have been struggling with this problem for quite some time. Basically
i have an asp page (on the ISP server) that I want to connect to a sql
server on another machine (on my server) and I have been trying to
figure out how to do this. I tried to connect using an ip address in
the data source and it did not work. The asp.net code looks something
like this:

Conn.Open ("Provider=SQLOLEDB;Password=xxxx;Persist Security
Info=True;User ID=xxxx;Initial Catalog=mssqlxxx;Data
Source=xx.xxx.xxx.xxx,1433;Network Library=dbmssocn")

That did not work. Gave me an access denied or sql server does not
exist error. I tried playing around with or without the 1433 port,
still no luck.

Is there something I need to set up on sql server in order for me to
connect to this?? Can someone give me some suggestion how i can connect
to another computer?

My ISP offers sql server support and they give me an ip address to
connect directly to the sql server, code looks something like this:

conMyData = New SqlConnection( "Server=xxxxxxxxx.registeredsite.com;
UID=userxxxxxx; PWD=xxxxxx;Database=samplecom" )

now, my question is, how do I set up my sql server to have an ip
address so i can connect??

so i see 2 possible w ays to do this but i have no clue to make this
work. Any help is appreciated.This article might be useful:

http://www.aspfaq.com/show.asp?id=2126

Simon

Monday, March 26, 2012

How to connect to sql server 2000 (asp.net)

hi everybody, i got this error in my code.

Server Error in '/' Application.


SQL Server does not exist or access denied.

Source Error:

 
Line 12:       Dim SQLConn As SqlConnection = New SqlConnection()
Line 13:                SQLConn.ConnectionString = ConfigurationSettings.AppSettings("ConnectionString")
Line 14:                SQLConn.Open()
Line 15:       
Line 16:       cmdLath = New SqlCommand ( _

my web.config

<configuration>

<appSettings>

<addkey="ConnectionString" value="DataSource=xxx;UID=xxx;pwd=xxx" />

<addkey="ConnectionString" value="Server=xxx.xxx.x.x;database=xxx;UID=xxx;pwd=xxx;Trusted_Connection=True"/>

</appSettings>

<system.web>

<sessionState cookieless="false" timeout="20"/>

<customErrorsmode="Off"/>

</system.web>

</configuration>

what seems to be a problem, please help me??Is your connection string correct (server address, username, password, etc.)? Does the user your authenticating as have the correct permissions on the database?

Ryan|||i ran into this problem a few weeks ago as well, like the previous poster stated, you have to make sure they have an account in the sql server itself, not just a windows account. So the problem isn't with your code (assuming no spelling errors or the such) but with the sql server authenticating the user name and password. Hope that helps.|||Besides the suggestions given above, make sure you have SQL Server Authentication configured to be Mixed mode. Checkthis for the configuration.|||To Strongtypes,

Yes, I write the correct server, database, username and password. basically i use sa account with password but it didn't work. I used sql server authentication mixed mode.|||To Darkempire and Alvin,

Thanks for the reply, You know I've done a lot of codes in my asp.net but unfortunately it appears errors in my webpage. This is my setup, my sql server 2000 is installed on other machine with the domain controller running windows server 2003. I have this local pc with my asp.net with web server(iis). I think that my web server does not locate my sql server database or my connection string is wrong but if I'm going to used my dreamweavermx to fetch data to my sql server database it will show up perfectly but when i code an asp.net and run in my localhost, bang errorrs.. please help me|||

Let's do a connection testing on teh .NET client machine: new a '.udl' file e.g. test.udl, then double click to edit it->switch to Provider tab and choose 'SQL Native Client' (which is the default provider when you add connectionstring element in your web.config)->click next to switch to Connection tab->entering connection information including login and pasword (the same as you connect to the SQL Server in DreamWeaver)->click Test Connection. If this succeeds, then the SQL Native Client provider is OK; otherwise there's something wrong with the SQL Native Client provider, so you need to change another provider.

To learn more about connection strings using different providers, you can visit:

www.connectionstrings.com

sql

How to Connect to a SQL server on a deferent machine using ASP.Net?

Hi,

I am trying to connect to a SQL server on a deferent machine using ASP.Net written in C#. The machine on which the SQL server reside dose not have the ASPNET user and the authentication is falling. Any ideas on how to connect using a different User. I changed the ASP.Net service on my machine to run as a deferent user MyUser, which is a domain user that have access to the server machine?

Note: We can not change the privileges on the server side.

Thanks.

RH

Hi,

I am looking to run a web service as a deferent user; it is running, as ASPNET and I would like it to run as a domain user. I am not sure if this is a configuration issue in the Dev studio. Please help.

Thanks.

Rafat

|||

You should post on an ASP.Net forum for instructions on how to set a specific login to be used by your application for connecting to SQL Server.

If you have questions about how to setup such a login in SQL Server, let us know.

Thanks
Laurentiu

|||

Please don't open different threads on the same topic.

Thanks
Laurentiu

Friday, March 23, 2012

How to Connect SQL server Using ASP.net

Dear ASP.NET user...

I'm a new user in ASP.NET...
i have a problem facing now...
I'm using SQL server as my database...
how do i CONNECT my web application using ASP.NET to SQL server??

What should i do?
any coding do i need to insert to my web HTML?

what i heard from my friend...she said web config can connect the web application to SQL server...?...it that work?

pls help me guys and gals...

From jhwong2610
URGENTVery often the web.config is used to store the connection string - that alone does not connect you to a database - using the connection string you have to open a sqlConnection and then proceed from there.

My best recommendation would be to pick up one of the ASP.NET books and look at one of the examples that uses data binding.|||Hi:
Like This


Dim Conn As New SqlConnection("ConnectionStringHere")
Dim Conn As New SqlCommand("Select * From Table", Conn)
Dim DRs As SqlDataReader
Conn.Open()
DRs = Comm.ExecuteReader()
If DRs.Read() Then
Response.Write(DRs("Column"))
End If
DRs.Close()
Conn.Close()
|||Add this to the web.config file:

<configuration>
<appSettings>
<add key="SQLConnStr" value="<your connection string" />
</appSettings
...

You can use the connectionstring in the code like this:

Dim str as connStr = System.Configuration.ConfigurationSettings.AppSettings("SQLConnStr")

Wednesday, March 21, 2012

how to connect asp.net to sql server 2k

i have this error in my asp.net

>Server Error in '/' Application.
>------------------------
>SQL Server does not exist or access denied.
>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
>Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.
>Source Error:
>
>Line 23: Dim sText As String = "SELECT employeeid, firstname, lastname FROM Employees"
>Line 24: Dim cmd As SqlDataAdapter= New SqlDataAdapter(sText, sConn)
>Line 25: cmd.Fill(ds, "EmpTable")
>Line 26:
>Line 27: Session("MyData") = ds
>
>Source File: c:\inetpub\wwwroot\FormViewer.aspx Line: 25

and my connection string is :

>"server=localhost;uid=sa;Initial Catalog=Northwind;"

i tried a lot of codes but it doesn't work in sql server 2k but in mysql server it perfectly run. i installed my web server in my local machine with .net framework but my sql server 2k is installed in other machine with the domain controller setup. how im going to connect to my sql server 2k using asp.net codes. i learn some ideas that it better to code the connection string in web.config. is it ok? please please help me. im really out of mind.hi everybody, im a newbie in asp.net. my current language is vb/sqlserver2k. i have a problem in connecting asp.net to sql server2k because my sql server2k is installed in other machine and my web server is installed in my local machine together with my .net framework. i tried a lot of examples but none of this is working with application, it shows with an error "SQL Server does not exist or access denied."
can you give me a complete source step by step. i would really appreciate if anybody can help. thanks in advance|||Tryhttp://www.connectionstrings.com for connection string help. If you still can't get it working, is your SQL Server using SQL authentication or Windows authentication? What does your connection string look like (be sure not to post actual user names and passwords if you are using SQL authentication)?

Edit: I found your duplicate post on the same topic and joined it to this thread. Please do not post the same question multiple times. It only frustrates those who are trying to help you and dilutes the effort.|||how can i know what authentication am i using, sql authentication or windows authentication?
all i know that in my vb application i was using this connection string to connect to my sql server "provider=sqloledb;database=xxxx;server=xxxx;uid=xxx;pwd=xxxx" is that so simple in my vb but in asp.net i really don't know what is the correct connection. thanks anyway tmorton for your reply|||Use the connection string example under SQL Server, SqlConnection, Standard Security at connectionstrings.com.

You are using SQL authentication since you are using a user name and password to connect. If you were using Windows authentication there would be no user name or password; the credentials of the current user would be used.

Monday, March 19, 2012

how to configure multiple databases for one asp.net website

Hello:
I am working on a website that will require the use of multiple
databases - a unique database for each user in fact. It is somewhat of
a light CRM application and it is important to keep a user's customer
information in their own database.
So I am hoping to get input on the best way to implement this. The
approach I am using so far includes storing the database connection
string in a property of the user's profile object. However, this
requires referencing the profile object each time I hit the database.
And for pages that are using the sqldatasource control, that means
assigning the connectionstring property for that control in the
page_load event outside of an "if not page.ispostback" block. So I
wonder if there isn't a better way.
Any feedback would be really appreciated here.
ChrisHow about storing the user's database name in their profile object and/or in
a session variable. Then you can prefix all of your calls with the database
name:
... "EXEC " + session("database_name") + ".dbo.ProcedureName";
Of course, if you are doing this for scalability reasons, you will probably
want to consider multiple connection strings for different servers...
<chrishalldba@.yahoo.com> wrote in message
news:1138581470.361914.172540@.o13g2000cwo.googlegroups.com...
> Hello:
> I am working on a website that will require the use of multiple
> databases - a unique database for each user in fact. It is somewhat of
> a light CRM application and it is important to keep a user's customer
> information in their own database.
> So I am hoping to get input on the best way to implement this. The
> approach I am using so far includes storing the database connection
> string in a property of the user's profile object. However, this
> requires referencing the profile object each time I hit the database.
> And for pages that are using the sqldatasource control, that means
> assigning the connectionstring property for that control in the
> page_load event outside of an "if not page.ispostback" block. So I
> wonder if there isn't a better way.
> Any feedback would be really appreciated here.
> Chris
>|||How about storing the user's database name in their profile object and/or in
a session variable. Then you can prefix all of your calls with the database
name:
... "EXEC " + session("database_name") + ".dbo.ProcedureName";
Of course, if you are doing this for scalability reasons, you will probably
want to consider multiple connection strings for different servers...
<chrishalldba@.yahoo.com> wrote in message
news:1138581470.361914.172540@.o13g2000cwo.googlegroups.com...
> Hello:
> I am working on a website that will require the use of multiple
> databases - a unique database for each user in fact. It is somewhat of
> a light CRM application and it is important to keep a user's customer
> information in their own database.
> So I am hoping to get input on the best way to implement this. The
> approach I am using so far includes storing the database connection
> string in a property of the user's profile object. However, this
> requires referencing the profile object each time I hit the database.
> And for pages that are using the sqldatasource control, that means
> assigning the connectionstring property for that control in the
> page_load event outside of an "if not page.ispostback" block. So I
> wonder if there isn't a better way.
> Any feedback would be really appreciated here.
> Chris
>|||Aaron:
Thanks for your reply. I actually left out some stuff in my post to
keep the thread somewhat open-ended. Your suggestion actually looks
very close to what I ended up implementing. I am storing a database
connection string in a profile object, then loading that into a session
variable when the user logs in. It sounds like I'm on the right track
so that's reassuring. Thanks for the peace of mind!
Chris

Friday, February 24, 2012

How to code ASP.NET page with return value Store Procedure?

Does anyone know how to call a SQL store procedure that return a value to the page?

I've a simple data entry aspx page with several textboxes and a save button. When user fill out the form and click save/submit, it calls a store procedure to insert a row into a SQL table and automatically generate an ID that need to return the the page to display for the user.

Are there a similar article somewhere?

Thank you all!

check out the docs about using ExecuteScalar() Method.|||

Using ExecuteScalar() requires a separate procedure call. I would like to use the same procedure call that to insert a record into a table and also return an ID back. My store procedure look like this:

sqlString = "EXEC spInsertRow 'parm1','parm2','parm3', @.ReturnID OUTPUT"

Thanks

|||

In the end of your sproc:

SELECT @.ReturnID = @.@.IDENTITY

|||

I suggested ExecuteScalar assuming you are doing some insert and want to return the ID.

If that is not the case you can use the OUTPUT parameters..

Dim res as integer

myParam = mycommand.CreateParameter()
myParam.ParameterName = "@.returnId"
myParam.Direction = ParameterDirection.Output
myParam.SqlDbType = SqlDbType.bigint
mycommand.Parameters.Add(myParam)

res = mycommand.Parameters("@.result").Value

|||

Thank you. It works

|||

Can you share your general procedure. I'm having the same issue and have tested many ways. Still not working.

See posthttp://forums.asp.net/1178243/ShowPost.aspx

Thanks