Showing posts with label connection. Show all posts
Showing posts with label connection. Show all posts

Wednesday, March 21, 2012

Newbie Q regarding opening a connection to a database

Hello, Im new with databases.

I know that opening a connection to a DB is expensive. Usually I write a method that opens a connection to the DB then I execute a query and then close the connection. Pretty standard.

OK, so how do I handle opening connections to the database when I need to run multiple queries. For example, i have a webpage that need to query the database to see if the user has moderator privledges, then depending on that query I have to query the DB again for moderator specific information or non-modertaor information.

So in this case how do i handle opening connections to the DB. Is it ok to generally have to open a connection to a DB multiple times on a page load?

The obvious solution is to keep the connection open. That is, open a connection, query the Db, keep the connection open, do the conditional statment ( if is_Moderator) then query the DB again for the info that I need, and then close the connection. But, from all the books that Ive been reading this is not a good practice because business logic should not been in the dataAccess layer.

Any help would be much appreciated.You should be using stored procedures to do all of this. Then this wouldn't be a problem. You could have a "wrapper" stored procedure that figures out if it's a moderator or not, then calls the appropriate stored procedure based on that information. You then wouldn't have to worry about multiple calls to the database. This is a data logic procedure. It's not "always" bad to have business logic at the database layer. It's questionable that this is even business logic.

Make sense?|||yes it did make sense.

Thankyou.

newbie Q

Hi, and Thanks for your thoughts!
I am evaluating a product, and the sales team presents an
option I am not familiar with.
Can a SQL/OBDC connection accross the internet be
encrypted (via or utilizing) OBDC?
Any heads-up or caveats will be appreciated.
Brent
Yes, SQL Server (and therefore the ODBC driver) supports encrypting the
connection.
Brannon
"Brent D." <anonymous@.discussions.microsoft.com> wrote in message
news:1ba901c4a0dd$452c3c40$a601280a@.phx.gbl...
> Hi, and Thanks for your thoughts!
> I am evaluating a product, and the sales team presents an
> option I am not familiar with.
> Can a SQL/OBDC connection accross the internet be
> encrypted (via or utilizing) OBDC?
> Any heads-up or caveats will be appreciated.
> Brent

Monday, March 19, 2012

Newbie pie chart report problem

Hi, I've just started using Pie Charts and I'm stuck on a value problem (I think!). My category will be "Connection Status", and the values can be: success:human; success:machine; Connected; Null.

What I want to do is merge the "success:human" and "connected" values into one slice of pie. Is this possible?

Thanks, Dan

Sorry, I was confused, just needed to change the SQL to include both values.

newbie on SQL Server needs some direction .adp and .mde

I'm trying to figure out what is going on. I have an .adp file that has a
connection DNS to a .mde file on the network. It is confusing. In the
connection dialog it has my computer as the server name and it has the
database I am using to connect to the database I want. How can I find out
what is the DNS database source? It seems like it is connected to itself
instead of the right DNS. I don't see any tables in tables but I do get a
list of queries on the server so it must be connected but why don't I see the
tables as well? This is the one I would like to use but I don't get the
world icons that show the real SQL server data. In fact I don't even see the
tables on the access .mde file.
I try to view some queries and I get the error message "ADO error: MSDTC
on Server 'myComputer' is not available. I have MS SQL Server running in
Services as well as SQL Server express. Mainly because I don't know which one
is best. I also get the error 'Ole DB error trace Ole 10B Profvider MS Jet
OlebDB 4.0 Open rowset returned ox.... The specified table does not exist'
which I think means the query cannot access the tables. Why can I get the
queries and not the tables?
If I access it through terminal server access frontend I can make changes to
the queries. I also can see the tables which include dbo tables on a Server
but I would rather write my queries on my own desktop version and not do
anything on the terminal services version.
On the terminal services .mde database there are some pass through queries.
In fact the one I think I need appear to be a pass through query. If I open
the query the data is 2 years old. Can I make a make table from the pass
through query to see if it updates the data? I really do not want to do
anything wrong to the frontend db on terminal services but I need to write
this one query for a report.
tia,DNS are only a name given to a connection string. You don't have to use a
DSN to connect to a SQL-Server; it's only one possibility amongst others.
Second, DNS are only for ODBC while ADP use only ADO. So, you cannot use a
DSN with ADP and even with ADO, ADP can connect only to a SQL-Server and not
to a MDB or a MDE file. Also, the fact that you can connect to a sql-server
doesn't mean that you will be able to see everything (tables, views, sp,
functions, etc.) on the server because of permission issues.
Looks like that you have copied an ADP file from a terminal server to a
local machine but that the permissions on the server are set to block you
from accessing the data from outside the forms in the ADP project or
something like that.
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)
"Janis" <Janis@.discussions.microsoft.com> wrote in message
news:7333903F-5E59-4DF0-8BAB-5C45137AF7A5@.microsoft.com...
> I'm trying to figure out what is going on. I have an .adp file that has a
> connection DNS to a .mde file on the network. It is confusing. In the
> connection dialog it has my computer as the server name and it has the
> database I am using to connect to the database I want. How can I find out
> what is the DNS database source? It seems like it is connected to itself
> instead of the right DNS. I don't see any tables in tables but I do get a
> list of queries on the server so it must be connected but why don't I see
> the
> tables as well? This is the one I would like to use but I don't get the
> world icons that show the real SQL server data. In fact I don't even see
> the
> tables on the access .mde file.
> I try to view some queries and I get the error message "ADO error: MSDTC
> on Server 'myComputer' is not available. I have MS SQL Server running in
> Services as well as SQL Server express. Mainly because I don't know which
> one
> is best. I also get the error 'Ole DB error trace Ole 10B Profvider MS
> Jet
> OlebDB 4.0 Open rowset returned ox.... The specified table does not
> exist'
> which I think means the query cannot access the tables. Why can I get the
> queries and not the tables?
>
> If I access it through terminal server access frontend I can make changes
> to
> the queries. I also can see the tables which include dbo tables on a
> Server
> but I would rather write my queries on my own desktop version and not do
> anything on the terminal services version.
> On the terminal services .mde database there are some pass through
> queries.
> In fact the one I think I need appear to be a pass through query. If I
> open
> the query the data is 2 years old. Can I make a make table from the pass
> through query to see if it updates the data? I really do not want to do
> anything wrong to the frontend db on terminal services but I need to write
> this one query for a report.
> tia,

Monday, March 12, 2012

newbie IIS & MS SQL connection problem ;-(

Have successfully installed MS SQL on my Win XP Pro machine, created tables,
and a dsn, which is working fine in Dreamweaver. So far so good.

When I run the page on IIS I get the following:-

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database
requested in login 'MenuPlanner'. Login fails.

I think it's permissions - anyone got any clues as to where to look?

TIA

GrantBuzby wrote:
> Have successfully installed MS SQL on my Win XP Pro machine, created
tables,
> and a dsn, which is working fine in Dreamweaver. So far so good.
> When I run the page on IIS I get the following:-
> Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
> [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database
> requested in login 'MenuPlanner'. Login fails.
> I think it's permissions - anyone got any clues as to where to look?

You could see if the login MenuPlanner has got permissions to the
database you are logging in to. That would be a start.

--
David Rowland
For a good user and performance monitor, check DBMonitor
http://dbmonitor.tripod.com

> TIA
> Grant|||"dbmonitor" <dbmonitor_support@.hotmail.com> wrote in message
news:1107519068.678569.226760@.o13g2000cwo.googlegr oups.com...
> Buzby wrote:
>> Have successfully installed MS SQL on my Win XP Pro machine, created
> tables,
>> and a dsn, which is working fine in Dreamweaver. So far so good.
>>
>> When I run the page on IIS I get the following:-
>>
>> Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
>> [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database
>> requested in login 'MenuPlanner'. Login fails.
>>
>> I think it's permissions - anyone got any clues as to where to look?
> You could see if the login MenuPlanner has got permissions to the
> database you are logging in to. That would be a start.

This is what has got me - permissions are set up. I've created a dsn, which
I can run queries in Dreamweaver and filter results just fine. I'm having
trouble when running the page on my webserver (IIS which is working fine)

Stumped ;-(|||Buzby wrote:
> "dbmonitor" <dbmonitor_support@.hotmail.com> wrote in message
> news:1107519068.678569.226760@.o13g2000cwo.googlegr oups.com...
> > Buzby wrote:
> >> Have successfully installed MS SQL on my Win XP Pro machine,
created
> > tables,
> >> and a dsn, which is working fine in Dreamweaver. So far so good.
> >>
> >> When I run the page on IIS I get the following:-
> >>
> >> Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
> >> [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open
database
> >> requested in login 'MenuPlanner'. Login fails.
> >>
> >> I think it's permissions - anyone got any clues as to where to
look?
> > You could see if the login MenuPlanner has got permissions to the
> > database you are logging in to. That would be a start.
> This is what has got me - permissions are set up. I've created a dsn,
which
> I can run queries in Dreamweaver and filter results just fine. I'm
having
> trouble when running the page on my webserver (IIS which is working
fine)
> Stumped ;-(

Is MenuPlanner the database name or the login name?

If it is the database name, are you connecting to the database via a
userid/password or are you connecting with Windows interactive UserID?
--
David Rowland
For a good user and performance monitor, check DBMonitor
http://dbmonitor.tripod.com|||Buzby (gb@.pumpupthe.net) writes:
> Have successfully installed MS SQL on my Win XP Pro machine, created
> tables, and a dsn, which is working fine in Dreamweaver. So far so
> good.
> When I run the page on IIS I get the following:-
> Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
> [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database
> requested in login 'MenuPlanner'. Login fails.
> I think it's permissions - anyone got any clues as to where to look?

Sounds like the login has a default db which does not exist, or the login
does have access to. Use sp_helplogins to check, use sp_defaultdb to change.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||On 2/4/05 5:37 PM, in article Xns95F3F003A2514Yazorman@.127.0.0.1, "Erland
Sommarskog" <esquel@.sommarskog.se> wrote:

> Buzby (gb@.pumpupthe.net) writes:
>> Have successfully installed MS SQL on my Win XP Pro machine, created
>> tables, and a dsn, which is working fine in Dreamweaver. So far so
>> good.
>>
>> When I run the page on IIS I get the following:-
>>
>> Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
>> [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database
>> requested in login 'MenuPlanner'. Login fails.
>>
>> I think it's permissions - anyone got any clues as to where to look?
> Sounds like the login has a default db which does not exist, or the login
> does have access to. Use sp_helplogins to check, use sp_defaultdb to change.

Yea, but a DSN is being used so we have to believe that MenuPlanner is the
name of the DSN Connection. I am assuming that the DSN was created on the
IIS server and connects successfully when you "test connection" in the ODBC
dialog.

I highly recommend using a DSN-less connection in your ASP pages. There is
lots of documentation on ADODB.

If you need some sample connection strings let me know.|||Gregory Dean (gdean@.datapex.com) writes:
> On 2/4/05 5:37 PM, in article Xns95F3F003A2514Yazorman@.127.0.0.1, "Erland
> Sommarskog" <esquel@.sommarskog.se> wrote:
>> Buzby (gb@.pumpupthe.net) writes:
>>> Have successfully installed MS SQL on my Win XP Pro machine, created
>>> tables, and a dsn, which is working fine in Dreamweaver. So far so
>>> good.
>>>
>>> When I run the page on IIS I get the following:-
>>>
>>> Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
>>> [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database
>>> requested in login 'MenuPlanner'. Login fails.
>>>
>>> I think it's permissions - anyone got any clues as to where to look?
>>
>> Sounds like the login has a default db which does not exist, or the
>> login does have access to. Use sp_helplogins to check, use sp_defaultdb
>> to change.
> Yea, but a DSN is being used so we have to believe that MenuPlanner is
> the name of the DSN Connection. I am assuming that the DSN was created
> on the IIS server and connects successfully when you "test connection"
> in the ODBC dialog.

Not sure what you mean, but since SQL Server does not know what a DSN
is, MenuPlanner cannot be the name of the DNS. But it can be the
login name specified in the DSN.

> I highly recommend using a DSN-less connection in your ASP pages.

I echo that. DSN is a concept that I never understood the point with.
An extra layer that only causes hassle.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Thanks one and all - it turned out it was an IIS permissions issue - however
I've taken on board what you have suggested and dsn less is the way we are
going!

Cheers

Buzby

Friday, March 9, 2012

newbie having trouble with SQL connection, insert/update

Thanks to anyone who helps!
I'm building a data entry windows form that requires the data to
be sent to a SQL Server table (the table's name is "Local") when the
form's "SAVE" button is clicked. I've built the form using the windows
form designer, and now I'm attempting to use SQL statements to
insert/update data into the table. There are six fields that will use
SQL statements to send data to the Local table, and none of the fields
are permitted to be null values. Two of the fields are comboboxes that
are populated through the use of their own respective datasets
(DisasterType and Dwelling); the datasets were built using the forms
designer OLEdbDataAdapter. Three fields are textboxes(FamilyName,
WorkerName, and DamageDescGeneral) that require the user to manually
enter data. Finally, there is a checkbox (Utilities) that should be
checked if the parameter is "yes/true."
My main problem is that I don't know the correct SQL code that
will allow
the data to be inserted/updated into the Local table. Or, can the
issue be solved using the forms designer? There are also two other
issues.
1. The datatypes of the "Disaster Type" and "Dwelling" fields have to
be changed before being sent to the Local table. I am using the more
user-readable names and descriptions of the respective fields to
populate the form, rather than their Primary Key ID's. However, their
Primary Keys are also Foreign Keys in the Local table, so their
datatypes have to be changed. You'll see this attempted conversion in
the "//convert Disaster_Type to Disaster_ID" and "//convert
Dwelling_Desc to Dwelling_Type" statements. The compiler doesn't
recognize the While statement I'm using. Here is the error: Cannot
find method 'While(boolean)' in 'ArcMaster.frmLocal'
2. The datatype for the Utilities column in the Local table is a bit
value, but the datatype on the windows form is a boolean checkbox. I
need to be able to convert from boolean to bit through the use of an If
statement, but I keep getting errors. Here are my compile errors under
the current configuration:
Type 'boolean' is not assignable to 'Object'
Type 'int' is not assignable to 'Object'
I've included my code. I KNOW it's wrong, and I'm hoping
someone can
assist me. Thanks again!!!
import System.Drawing.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;
import System.Data.*;
import System.Data.SqlClient.*;
import System.*;
/**
* Summary description for Local.
*/
public class frmLocal extends System.Windows.Forms.Form
{
//windows forms designer variables
private System.Windows.Forms.Label lblTitle;
private System.Windows.Forms.TextBox txtFamilyName;
private System.Windows.Forms.Label lblFamilyName;
private System.Windows.Forms.TextBox txtWorkerName;
private System.Windows.Forms.Label lblWorkerName;
private System.Windows.Forms.Label lblDisasterType;
private System.Windows.Forms.ComboBox cboDisasterType;
private System.Windows.Forms.Label lblDwellingType;
private System.Windows.Forms.ComboBox cboDwellingType;
private System.Windows.Forms.Label lblUtilities;
private System.Windows.Forms.Label lblDegreeOfDamage;
private System.Windows.Forms.Label lblDamageDescGeneral;
private System.Windows.Forms.TextBox txtDamageDescGeneral;
private System.Windows.Forms.Button cmdCloseWindow;
private System.Windows.Forms.Button cmdClearEntry;
private System.Windows.Forms.Button cmdSave;
private System.Data.OleDb.OleDbConnection oleDbConnection1;
private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter3;
private System.Data.OleDb.OleDbCommand oleDbSelectCommand3;
private System.Data.OleDb.OleDbCommand oleDbInsertCommand3;
private System.Data.OleDb.OleDbCommand oleDbUpdateCommand3;
private System.Data.OleDb.OleDbCommand oleDbDeleteCommand3;
private ArcMaster.dsDisasterType dsDisasterType1;
private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter4;
private System.Data.OleDb.OleDbCommand oleDbSelectCommand4;
private System.Data.OleDb.OleDbCommand oleDbInsertCommand4;
private System.Data.OleDb.OleDbCommand oleDbUpdateCommand4;
private System.Data.OleDb.OleDbCommand oleDbDeleteCommand4;
private ArcMaster.dsDwelling dsDwelling1;
private System.Windows.Forms.CheckBox chkUtilities;
/**
* Required designer variable.
*/
private System.ComponentModel.Container components = null;
public frmLocal()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent
call
//
}
/**
* Clean up any resources being used.
*/
protected void Dispose(boolean disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
super.Dispose(disposing);
}
#region Windows Form Designer generated code
private void frmLocal_Load (Object sender, System.EventArgs e)
{
//populate disaster type combobox with data from Disaster_Type
table
dsDisasterType1.Clear();
oleDbDataAdapter3.Fill(dsDisasterType1);
oleDbConnection1.Close();
//populate dwelling type combobox with data from Dwelling table
dsDwelling1.Clear();
oleDbDataAdapter4.Fill(dsDwelling1);
oleDbConnection1.Close();
}
private void cmdSave_Click (Object sender, System.EventArgs e)
{
//SQL variables
Object sql;
SqlConnection cn;
DataSet dsLocal = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand myCommand;
SqlDataReader reader;
//initialize the variables that handle data to be bound to
Local table;
Object FamilyName = txtFamilyName.get_Text();
Object Dwelling = cboDwellingType.get_SelectedItem();
Object DisasterType = cboDisasterType.get_SelectedItem();
Object WorkerName = txtWorkerName.get_Text();
Object DamageDescGeneral = txtDamageDescGeneral.get_Text();
Object Utilities = chkUtilities.get_CheckState();
//Set the connection string of the SqlConnection object to
connect to the ARC database
cn = new SqlConnection("Server=METZLER"+
"Integrated security=SSPI;" +
"database=ARC");
myCommand= new SqlCommand(sql, cn);
cn.Open();
//convert Disaster_Type to Disaster_ID
sql = "SELECT Disaster_ID FROM Disaster_Type WHERE
((Disaster_Name = " + DisasterType + " ))";
reader = myCommand.ExecuteReader();
While(reader.Read());
{
DisasterType = reader.GetValue(0);
}
reader.Close();
//convert Dwelling_Desc to Dwelling_Type
sql = "SELECT Dwelling_Type FROM Dwelling WHERE ((Dwelling_Desc
= " + Dwelling + "))";
reader = myCommand.ExecuteReader();
While(reader.Read());
{
Dwelling = reader.GetValue(0);
}
reader.Close();
//Initialize the SqlCommandBuilder object to automatically
generate and
//initialize the UpdateCommand, the InsertCommand, and the
DeleteCommand
//properties of the SqlDataAdapter.
cmdBuilder = new SqlCommandBuilder(da);
da.Fill(dsLocal, "Local");
//convert Utilites data from text datatype to bit datatype
If (Utilities = true);
{
Utilities = 1;
}
If (Utilities = false);
{
Utilities = 0;
}
//SQL statement to insert data into Local table
sql = "INSERT INTO Local (Local_rowguid, ARC_Worker,
Description, Disaster_ID, Dwelling_Type, Family_Name, Utilities)" +
"VALUES (NewID(),'" + WorkerName + "', '" + DamageDescGeneral
+ "',
'" + DisasterType + "', '" + Dwelling + "', '" + FamilyName + "', '" +
Utilities;
da.Update(dsLocal, "Local");
//oleDbDataAdapter4.Update(dsDescriptionOfDamage1);
//oleDbConnection1.Close();
//dsLocal1.Clear();
//oleDbDataAdapter4.Update(dsLocal1);
//oleDbDataAdapter4.Fill(dsLocal1);
//oleDbConnection1.Close();
//oleDbConnection1.Close();
//Close the database connection.
cn.Close();
MessageBox.Show("Local Detailed Damage Assessment has been
updated.");
}
private void cmdCloseWindow_Click (Object sender, System.EventArgs e)
{
Close();Hi
You insert statement does not have a closing bracket, you also seem to be
making values strings by enquoting them when they are not character data
types. You could form the sql string differently depending on whether
utility is true or not.
John
"pmetz" <p1metzler@.yahoo.com> wrote in message
news:1144497354.135933.54280@.i40g2000cwc.googlegroups.com...
>
> Thanks to anyone who helps!
> I'm building a data entry windows form that requires the data to
> be sent to a SQL Server table (the table's name is "Local") when the
> form's "SAVE" button is clicked. I've built the form using the windows
>
> form designer, and now I'm attempting to use SQL statements to
> insert/update data into the table. There are six fields that will use
> SQL statements to send data to the Local table, and none of the fields
> are permitted to be null values. Two of the fields are comboboxes that
>
> are populated through the use of their own respective datasets
> (DisasterType and Dwelling); the datasets were built using the forms
> designer OLEdbDataAdapter. Three fields are textboxes(FamilyName,
> WorkerName, and DamageDescGeneral) that require the user to manually
> enter data. Finally, there is a checkbox (Utilities) that should be
> checked if the parameter is "yes/true."
> My main problem is that I don't know the correct SQL code that
> will allow
> the data to be inserted/updated into the Local table. Or, can the
> issue be solved using the forms designer? There are also two other
> issues.
>
> 1. The datatypes of the "Disaster Type" and "Dwelling" fields have to
> be changed before being sent to the Local table. I am using the more
> user-readable names and descriptions of the respective fields to
> populate the form, rather than their Primary Key ID's. However, their
> Primary Keys are also Foreign Keys in the Local table, so their
> datatypes have to be changed. You'll see this attempted conversion in
> the "//convert Disaster_Type to Disaster_ID" and "//convert
> Dwelling_Desc to Dwelling_Type" statements. The compiler doesn't
> recognize the While statement I'm using. Here is the error: Cannot
> find method 'While(boolean)' in 'ArcMaster.frmLocal'
>
> 2. The datatype for the Utilities column in the Local table is a bit
> value, but the datatype on the windows form is a boolean checkbox. I
> need to be able to convert from boolean to bit through the use of an If
>
> statement, but I keep getting errors. Here are my compile errors under
>
> the current configuration:
> Type 'boolean' is not assignable to 'Object'
> Type 'int' is not assignable to 'Object'
>
> I've included my code. I KNOW it's wrong, and I'm hoping
> someone can
> assist me. Thanks again!!!
>
> import System.Drawing.*;
> import System.Collections.*;
> import System.ComponentModel.*;
> import System.Windows.Forms.*;
> import System.Data.*;
> import System.Data.SqlClient.*;
> import System.*;
>
> /**
> * Summary description for Local.
> */
> public class frmLocal extends System.Windows.Forms.Form
> {
>
> //windows forms designer variables
> private System.Windows.Forms.Label lblTitle;
> private System.Windows.Forms.TextBox txtFamilyName;
> private System.Windows.Forms.Label lblFamilyName;
> private System.Windows.Forms.TextBox txtWorkerName;
> private System.Windows.Forms.Label lblWorkerName;
> private System.Windows.Forms.Label lblDisasterType;
> private System.Windows.Forms.ComboBox cboDisasterType;
> private System.Windows.Forms.Label lblDwellingType;
> private System.Windows.Forms.ComboBox cboDwellingType;
> private System.Windows.Forms.Label lblUtilities;
> private System.Windows.Forms.Label lblDegreeOfDamage;
> private System.Windows.Forms.Label lblDamageDescGeneral;
> private System.Windows.Forms.TextBox txtDamageDescGeneral;
> private System.Windows.Forms.Button cmdCloseWindow;
> private System.Windows.Forms.Button cmdClearEntry;
> private System.Windows.Forms.Button cmdSave;
> private System.Data.OleDb.OleDbConnection oleDbConnection1;
> private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter3;
> private System.Data.OleDb.OleDbCommand oleDbSelectCommand3;
> private System.Data.OleDb.OleDbCommand oleDbInsertCommand3;
> private System.Data.OleDb.OleDbCommand oleDbUpdateCommand3;
> private System.Data.OleDb.OleDbCommand oleDbDeleteCommand3;
> private ArcMaster.dsDisasterType dsDisasterType1;
> private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter4;
> private System.Data.OleDb.OleDbCommand oleDbSelectCommand4;
> private System.Data.OleDb.OleDbCommand oleDbInsertCommand4;
> private System.Data.OleDb.OleDbCommand oleDbUpdateCommand4;
> private System.Data.OleDb.OleDbCommand oleDbDeleteCommand4;
> private ArcMaster.dsDwelling dsDwelling1;
> private System.Windows.Forms.CheckBox chkUtilities;
>
> /**
> * Required designer variable.
> */
> private System.ComponentModel.Container components = null;
>
> public frmLocal()
> {
> //
> // Required for Windows Form Designer support
> //
> InitializeComponent();
>
> //
> // TODO: Add any constructor code after InitializeComponent
> call
> //
>
> }
>
> /**
> * Clean up any resources being used.
> */
> protected void Dispose(boolean disposing)
> {
> if (disposing)
> {
> if (components != null)
> {
> components.Dispose();
> }
> }
> super.Dispose(disposing);
>
> }
>
> #region Windows Form Designer generated code
> private void frmLocal_Load (Object sender, System.EventArgs e)
> {
> //populate disaster type combobox with data from Disaster_Type
> table
> dsDisasterType1.Clear();
> oleDbDataAdapter3.Fill(dsDisasterType1);
> oleDbConnection1.Close();
>
> //populate dwelling type combobox with data from Dwelling table
>
> dsDwelling1.Clear();
> oleDbDataAdapter4.Fill(dsDwelling1);
> oleDbConnection1.Close();
>
> }
>
> private void cmdSave_Click (Object sender, System.EventArgs e)
> {
> //SQL variables
> Object sql;
> SqlConnection cn;
> DataSet dsLocal = new DataSet();
> SqlDataAdapter da = new SqlDataAdapter();
> SqlCommand myCommand;
> SqlDataReader reader;
> //initialize the variables that handle data to be bound to
> Local table;
> Object FamilyName = txtFamilyName.get_Text();
> Object Dwelling = cboDwellingType.get_SelectedItem();
> Object DisasterType = cboDisasterType.get_SelectedItem();
> Object WorkerName = txtWorkerName.get_Text();
> Object DamageDescGeneral = txtDamageDescGeneral.get_Text();
> Object Utilities = chkUtilities.get_CheckState();
>
> //Set the connection string of the SqlConnection object to
> connect to the ARC database
> cn = new SqlConnection("Server=METZLER"+
> "Integrated security=SSPI;" +
> "database=ARC");
>
> myCommand= new SqlCommand(sql, cn);
>
> cn.Open();
>
> //convert Disaster_Type to Disaster_ID
> sql = "SELECT Disaster_ID FROM Disaster_Type WHERE
> ((Disaster_Name = " + DisasterType + " ))";
> reader = myCommand.ExecuteReader();
> While(reader.Read());
> {
> DisasterType = reader.GetValue(0);
> }
> reader.Close();
>
> //convert Dwelling_Desc to Dwelling_Type
> sql = "SELECT Dwelling_Type FROM Dwelling WHERE ((Dwelling_Desc
>
> = " + Dwelling + "))";
> reader = myCommand.ExecuteReader();
> While(reader.Read());
> {
> Dwelling = reader.GetValue(0);
> }
> reader.Close();
>
> //Initialize the SqlCommandBuilder object to automatically
> generate and
> //initialize the UpdateCommand, the InsertCommand, and the
> DeleteCommand
> //properties of the SqlDataAdapter.
> cmdBuilder = new SqlCommandBuilder(da);
>
> da.Fill(dsLocal, "Local");
>
> //convert Utilites data from text datatype to bit datatype
> If (Utilities = true);
> {
> Utilities = 1;
> }
> If (Utilities = false);
> {
> Utilities = 0;
> }
>
> //SQL statement to insert data into Local table
> sql = "INSERT INTO Local (Local_rowguid, ARC_Worker,
> Description, Disaster_ID, Dwelling_Type, Family_Name, Utilities)" +
> "VALUES (NewID(),'" + WorkerName + "', '" + DamageDescGeneral
> + "',
> '" + DisasterType + "', '" + Dwelling + "', '" + FamilyName + "', '" +
> Utilities;
>
> da.Update(dsLocal, "Local");
>
> //oleDbDataAdapter4.Update(dsDescriptionOfDamage1);
> //oleDbConnection1.Close();
> //dsLocal1.Clear();
> //oleDbDataAdapter4.Update(dsLocal1);
>
> //oleDbDataAdapter4.Fill(dsLocal1);
> //oleDbConnection1.Close();
> //oleDbConnection1.Close();
>
> //Close the database connection.
> cn.Close();
>
> MessageBox.Show("Local Detailed Damage Assessment has been
> updated.");
> }
>
> private void cmdCloseWindow_Click (Object sender, System.EventArgs e)
> {
> Close();
>

newbie having trouble with SQL connection, insert/update

Thanks to anyone who helps!
I'm building a data entry windows form that requires the data to
be sent to a SQL Server table (the table's name is "Local") when the
form's "SAVE" button is clicked. I've built the form using the windows
form designer, and now I'm attempting to use SQL statements to
insert/update data into the table. There are six fields that will use
SQL statements to send data to the Local table, and none of the fields
are permitted to be null values. Two of the fields are comboboxes that
are populated through the use of their own respective datasets
(DisasterType and Dwelling); the datasets were built using the forms
designer OLEdbDataAdapter. Three fields are textboxes(FamilyName,
WorkerName, and DamageDescGeneral) that require the user to manually
enter data. Finally, there is a checkbox (Utilities) that should be
checked if the parameter is "yes/true."
My main problem is that I don't know the correct SQL code that
will allow
the data to be inserted/updated into the Local table. Or, can the
issue be solved using the forms designer? There are also two other
issues.
1. The datatypes of the "Disaster Type" and "Dwelling" fields have to
be changed before being sent to the Local table. I am using the more
user-readable names and descriptions of the respective fields to
populate the form, rather than their Primary Key ID's. However, their
Primary Keys are also Foreign Keys in the Local table, so their
datatypes have to be changed. You'll see this attempted conversion in
the "//convert Disaster_Type to Disaster_ID" and "//convert
Dwelling_Desc to Dwelling_Type" statements. The compiler doesn't
recognize the While statement I'm using. Here is the error: Cannot
find method 'While(boolean)' in 'ArcMaster.frmLocal'
2. The datatype for the Utilities column in the Local table is a bit
value, but the datatype on the windows form is a boolean checkbox. I
need to be able to convert from boolean to bit through the use of an If
statement, but I keep getting errors. Here are my compile errors under
the current configuration:
Type 'boolean' is not assignable to 'Object'
Type 'int' is not assignable to 'Object'
I've included my code. I KNOW it's wrong, and I'm hoping
someone can
assist me. Thanks again!!!
import System.Drawing.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;
import System.Data.*;
import System.Data.SqlClient.*;
import System.*;
/**
* Summary description for Local.
*/
public class frmLocal extends System.Windows.Forms.Form
{
//windows forms designer variables
private System.Windows.Forms.Label lblTitle;
private System.Windows.Forms.TextBox txtFamilyName;
private System.Windows.Forms.Label lblFamilyName;
private System.Windows.Forms.TextBox txtWorkerName;
private System.Windows.Forms.Label lblWorkerName;
private System.Windows.Forms.Label lblDisasterType;
private System.Windows.Forms.ComboBox cboDisasterType;
private System.Windows.Forms.Label lblDwellingType;
private System.Windows.Forms.ComboBox cboDwellingType;
private System.Windows.Forms.Label lblUtilities;
private System.Windows.Forms.Label lblDegreeOfDamage;
private System.Windows.Forms.Label lblDamageDescGeneral;
private System.Windows.Forms.TextBox txtDamageDescGeneral;
private System.Windows.Forms.Button cmdCloseWindow;
private System.Windows.Forms.Button cmdClearEntry;
private System.Windows.Forms.Button cmdSave;
private System.Data.OleDb.OleDbConnection oleDbConnection1;
private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter3;
private System.Data.OleDb.OleDbCommand oleDbSelectCommand3;
private System.Data.OleDb.OleDbCommand oleDbInsertCommand3;
private System.Data.OleDb.OleDbCommand oleDbUpdateCommand3;
private System.Data.OleDb.OleDbCommand oleDbDeleteCommand3;
private ArcMaster.dsDisasterType dsDisasterType1;
private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter4;
private System.Data.OleDb.OleDbCommand oleDbSelectCommand4;
private System.Data.OleDb.OleDbCommand oleDbInsertCommand4;
private System.Data.OleDb.OleDbCommand oleDbUpdateCommand4;
private System.Data.OleDb.OleDbCommand oleDbDeleteCommand4;
private ArcMaster.dsDwelling dsDwelling1;
private System.Windows.Forms.CheckBox chkUtilities;
/**
* Required designer variable.
*/
private System.ComponentModel.Container components = null;
public frmLocal()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent
call
//
}
/**
* Clean up any resources being used.
*/
protected void Dispose(boolean disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
super.Dispose(disposing);
}
#region Windows Form Designer generated code
private void frmLocal_Load (Object sender, System.EventArgs e)
{
//populate disaster type combobox with data from Disaster_Type
table
dsDisasterType1.Clear();
oleDbDataAdapter3.Fill(dsDisasterType1);
oleDbConnection1.Close();
//populate dwelling type combobox with data from Dwelling table
dsDwelling1.Clear();
oleDbDataAdapter4.Fill(dsDwelling1);
oleDbConnection1.Close();
}
private void cmdSave_Click (Object sender, System.EventArgs e)
{
//SQL variables
Object sql;
SqlConnection cn;
DataSet dsLocal = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand myCommand;
SqlDataReader reader;
//initialize the variables that handle data to be bound to
Local table;
Object FamilyName = txtFamilyName.get_Text();
Object Dwelling = cboDwellingType.get_SelectedItem();
Object DisasterType = cboDisasterType.get_SelectedItem();
Object WorkerName = txtWorkerName.get_Text();
Object DamageDescGeneral = txtDamageDescGeneral.get_Text();
Object Utilities = chkUtilities.get_CheckState();
//Set the connection string of the SqlConnection object to
connect to the ARC database
cn = new SqlConnection("Server=METZLER"+
"Integrated security=SSPI;" +
"database=ARC");
myCommand= new SqlCommand(sql, cn);
cn.Open();
//convert Disaster_Type to Disaster_ID
sql = "SELECT Disaster_ID FROM Disaster_Type WHERE
((Disaster_Name = " + DisasterType + " ))";
reader = myCommand.ExecuteReader();
While(reader.Read());
{
DisasterType = reader.GetValue(0);
}
reader.Close();
//convert Dwelling_Desc to Dwelling_Type
sql = "SELECT Dwelling_Type FROM Dwelling WHERE ((Dwelling_Desc
= " + Dwelling + "))";
reader = myCommand.ExecuteReader();
While(reader.Read());
{
Dwelling = reader.GetValue(0);
}
reader.Close();
//Initialize the SqlCommandBuilder object to automatically
generate and
//initialize the UpdateCommand, the InsertCommand, and the
DeleteCommand
//properties of the SqlDataAdapter.
cmdBuilder = new SqlCommandBuilder(da);
da.Fill(dsLocal, "Local");
//convert Utilites data from text datatype to bit datatype
If (Utilities = true);
{
Utilities = 1;
}
If (Utilities = false);
{
Utilities = 0;
}
//SQL statement to insert data into Local table
sql = "INSERT INTO Local (Local_rowguid, ARC_Worker,
Description, Disaster_ID, Dwelling_Type, Family_Name, Utilities)" +
"VALUES (NewID(),'" + WorkerName + "', '" + DamageDescGeneral
+ "',
'" + DisasterType + "', '" + Dwelling + "', '" + FamilyName + "', '" +
Utilities;
da.Update(dsLocal, "Local");
//oleDbDataAdapter4.Update(dsDescriptionOfDamage1);
//oleDbConnection1.Close();
//dsLocal1.Clear();
//oleDbDataAdapter4.Update(dsLocal1);
//oleDbDataAdapter4.Fill(dsLocal1);
//oleDbConnection1.Close();
//oleDbConnection1.Close();
//Close the database connection.
cn.Close();
MessageBox.Show("Local Detailed Damage Assessment has been
updated.");
}
private void cmdCloseWindow_Click (Object sender, System.EventArgs e)
{
Close();Hi
You insert statement does not have a closing bracket, you also seem to be
making values strings by enquoting them when they are not character data
types. You could form the sql string differently depending on whether
utility is true or not.
John
"pmetz" <p1metzler@.yahoo.com> wrote in message
news:1144497354.135933.54280@.i40g2000cwc.googlegroups.com...
>
> Thanks to anyone who helps!
> I'm building a data entry windows form that requires the data to
> be sent to a SQL Server table (the table's name is "Local") when the
> form's "SAVE" button is clicked. I've built the form using the windows
>
> form designer, and now I'm attempting to use SQL statements to
> insert/update data into the table. There are six fields that will use
> SQL statements to send data to the Local table, and none of the fields
> are permitted to be null values. Two of the fields are comboboxes that
>
> are populated through the use of their own respective datasets
> (DisasterType and Dwelling); the datasets were built using the forms
> designer OLEdbDataAdapter. Three fields are textboxes(FamilyName,
> WorkerName, and DamageDescGeneral) that require the user to manually
> enter data. Finally, there is a checkbox (Utilities) that should be
> checked if the parameter is "yes/true."
> My main problem is that I don't know the correct SQL code that
> will allow
> the data to be inserted/updated into the Local table. Or, can the
> issue be solved using the forms designer? There are also two other
> issues.
>
> 1. The datatypes of the "Disaster Type" and "Dwelling" fields have to
> be changed before being sent to the Local table. I am using the more
> user-readable names and descriptions of the respective fields to
> populate the form, rather than their Primary Key ID's. However, their
> Primary Keys are also Foreign Keys in the Local table, so their
> datatypes have to be changed. You'll see this attempted conversion in
> the "//convert Disaster_Type to Disaster_ID" and "//convert
> Dwelling_Desc to Dwelling_Type" statements. The compiler doesn't
> recognize the While statement I'm using. Here is the error: Cannot
> find method 'While(boolean)' in 'ArcMaster.frmLocal'
>
> 2. The datatype for the Utilities column in the Local table is a bit
> value, but the datatype on the windows form is a boolean checkbox. I
> need to be able to convert from boolean to bit through the use of an If
>
> statement, but I keep getting errors. Here are my compile errors under
>
> the current configuration:
> Type 'boolean' is not assignable to 'Object'
> Type 'int' is not assignable to 'Object'
>
> I've included my code. I KNOW it's wrong, and I'm hoping
> someone can
> assist me. Thanks again!!!
>
> import System.Drawing.*;
> import System.Collections.*;
> import System.ComponentModel.*;
> import System.Windows.Forms.*;
> import System.Data.*;
> import System.Data.SqlClient.*;
> import System.*;
>
> /**
> * Summary description for Local.
> */
> public class frmLocal extends System.Windows.Forms.Form
> {
>
> //windows forms designer variables
> private System.Windows.Forms.Label lblTitle;
> private System.Windows.Forms.TextBox txtFamilyName;
> private System.Windows.Forms.Label lblFamilyName;
> private System.Windows.Forms.TextBox txtWorkerName;
> private System.Windows.Forms.Label lblWorkerName;
> private System.Windows.Forms.Label lblDisasterType;
> private System.Windows.Forms.ComboBox cboDisasterType;
> private System.Windows.Forms.Label lblDwellingType;
> private System.Windows.Forms.ComboBox cboDwellingType;
> private System.Windows.Forms.Label lblUtilities;
> private System.Windows.Forms.Label lblDegreeOfDamage;
> private System.Windows.Forms.Label lblDamageDescGeneral;
> private System.Windows.Forms.TextBox txtDamageDescGeneral;
> private System.Windows.Forms.Button cmdCloseWindow;
> private System.Windows.Forms.Button cmdClearEntry;
> private System.Windows.Forms.Button cmdSave;
> private System.Data.OleDb.OleDbConnection oleDbConnection1;
> private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter3;
> private System.Data.OleDb.OleDbCommand oleDbSelectCommand3;
> private System.Data.OleDb.OleDbCommand oleDbInsertCommand3;
> private System.Data.OleDb.OleDbCommand oleDbUpdateCommand3;
> private System.Data.OleDb.OleDbCommand oleDbDeleteCommand3;
> private ArcMaster.dsDisasterType dsDisasterType1;
> private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter4;
> private System.Data.OleDb.OleDbCommand oleDbSelectCommand4;
> private System.Data.OleDb.OleDbCommand oleDbInsertCommand4;
> private System.Data.OleDb.OleDbCommand oleDbUpdateCommand4;
> private System.Data.OleDb.OleDbCommand oleDbDeleteCommand4;
> private ArcMaster.dsDwelling dsDwelling1;
> private System.Windows.Forms.CheckBox chkUtilities;
>
> /**
> * Required designer variable.
> */
> private System.ComponentModel.Container components = null;
>
> public frmLocal()
> {
> //
> // Required for Windows Form Designer support
> //
> InitializeComponent();
>
> //
> // TODO: Add any constructor code after InitializeComponent
> call
> //
>
> }
>
> /**
> * Clean up any resources being used.
> */
> protected void Dispose(boolean disposing)
> {
> if (disposing)
> {
> if (components != null)
> {
> components.Dispose();
> }
> }
> super.Dispose(disposing);
>
> }
>
> #region Windows Form Designer generated code
> private void frmLocal_Load (Object sender, System.EventArgs e)
> {
> //populate disaster type combobox with data from Disaster_Type
> table
> dsDisasterType1.Clear();
> oleDbDataAdapter3.Fill(dsDisasterType1);
> oleDbConnection1.Close();
>
> //populate dwelling type combobox with data from Dwelling table
>
> dsDwelling1.Clear();
> oleDbDataAdapter4.Fill(dsDwelling1);
> oleDbConnection1.Close();
>
> }
>
> private void cmdSave_Click (Object sender, System.EventArgs e)
> {
> //SQL variables
> Object sql;
> SqlConnection cn;
> DataSet dsLocal = new DataSet();
> SqlDataAdapter da = new SqlDataAdapter();
> SqlCommand myCommand;
> SqlDataReader reader;
> //initialize the variables that handle data to be bound to
> Local table;
> Object FamilyName = txtFamilyName.get_Text();
> Object Dwelling = cboDwellingType.get_SelectedItem();
> Object DisasterType = cboDisasterType.get_SelectedItem();
> Object WorkerName = txtWorkerName.get_Text();
> Object DamageDescGeneral = txtDamageDescGeneral.get_Text();
> Object Utilities = chkUtilities.get_CheckState();
>
> //Set the connection string of the SqlConnection object to
> connect to the ARC database
> cn = new SqlConnection("Server=METZLER"+
> "Integrated security=SSPI;" +
> "database=ARC");
>
> myCommand= new SqlCommand(sql, cn);
>
> cn.Open();
>
> //convert Disaster_Type to Disaster_ID
> sql = "SELECT Disaster_ID FROM Disaster_Type WHERE
> ((Disaster_Name = " + DisasterType + " ))";
> reader = myCommand.ExecuteReader();
> While(reader.Read());
> {
> DisasterType = reader.GetValue(0);
> }
> reader.Close();
>
> //convert Dwelling_Desc to Dwelling_Type
> sql = "SELECT Dwelling_Type FROM Dwelling WHERE ((Dwelling_Desc
>
> = " + Dwelling + "))";
> reader = myCommand.ExecuteReader();
> While(reader.Read());
> {
> Dwelling = reader.GetValue(0);
> }
> reader.Close();
>
> //Initialize the SqlCommandBuilder object to automatically
> generate and
> //initialize the UpdateCommand, the InsertCommand, and the
> DeleteCommand
> //properties of the SqlDataAdapter.
> cmdBuilder = new SqlCommandBuilder(da);
>
> da.Fill(dsLocal, "Local");
>
> //convert Utilites data from text datatype to bit datatype
> If (Utilities = true);
> {
> Utilities = 1;
> }
> If (Utilities = false);
> {
> Utilities = 0;
> }
>
> //SQL statement to insert data into Local table
> sql = "INSERT INTO Local (Local_rowguid, ARC_Worker,
> Description, Disaster_ID, Dwelling_Type, Family_Name, Utilities)" +
> "VALUES (NewID(),'" + WorkerName + "', '" + DamageDescGeneral
> + "',
> '" + DisasterType + "', '" + Dwelling + "', '" + FamilyName + "', '" +
> Utilities;
>
> da.Update(dsLocal, "Local");
>
> //oleDbDataAdapter4.Update(dsDescriptionOfDamage1);
> //oleDbConnection1.Close();
> //dsLocal1.Clear();
> //oleDbDataAdapter4.Update(dsLocal1);
>
> //oleDbDataAdapter4.Fill(dsLocal1);
> //oleDbConnection1.Close();
> //oleDbConnection1.Close();
>
> //Close the database connection.
> cn.Close();
>
> MessageBox.Show("Local Detailed Damage Assessment has been
> updated.");
> }
>
> private void cmdCloseWindow_Click (Object sender, System.EventArgs e)
> {
> Close();
>

Newbie Connection problems

Hi All
I am running a website on one server and need to be able to connect to
SQL 2000 on another server. When I try to connect to the SQL server
in an asp.net application I get the following error:
Login failed for user 'Domain\Server$'
How do I configure SQL to allow the other IIS server to connect.
TIA
Tony
Tony,
please can you post up your connectionstring that the SQLConnection object
is using. Also, do you want to use SQL authentication or Trusted, and what
is your SQL Server configured to allow - Mixed or Windows.
TIA,
Paul Ibison
|||From the error message it appears that the machine account is attempting to
connect to SQL Server, not a user account. You can get the connection to
work by adding a login for the machine account: Domain\server$. This is a
AD accounta nd many application use it to connect to SQL Server. It is
basically the machine system account.
Rand
This posting is provided "as is" with no warranties and confers no rights.

Newbie Connection problems

Hi All
I am running a website on one server and need to be able to connect to
SQL 2000 on another server. When I try to connect to the SQL server
in an asp.net application I get the following error:
Login failed for user 'Domain\Server$'
How do I configure SQL to allow the other IIS server to connect.
TIA
TonyTony,
please can you post up your connectionstring that the SQLConnection object
is using. Also, do you want to use SQL authentication or Trusted, and what
is your SQL Server configured to allow - Mixed or Windows.
TIA,
Paul Ibison|||From the error message it appears that the machine account is attempting to
connect to SQL Server, not a user account. You can get the connection to
work by adding a login for the machine account: Domain\server$. This is a
AD accounta nd many application use it to connect to SQL Server. It is
basically the machine system account.
Rand
This posting is provided "as is" with no warranties and confers no rights.

Newbie Connection Problem

I'm having a problem writing aconnection string in .NET. I'm trying to use:

SqlConnection myConnection = new SqlConnection("Provider=SQLOLEDB;Data Source=mssql;Initial Catalog= cat;UserId=ddd;Password=ddd;");

which unfortunately is giving me:

SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution ofthe current web request. Please review the stack trace for moreinformation about the error and where it originated in the code.

Can someone tell me what I'm doing wrong? Thanks in advance!

Edit/Delete Message

do you only have Windows Authentication setup for your SQL server?

or - if not -does the user you put in the connection string actually have an account in SQL Server?

|||We're not using Windows Authentication and there is a valid account being referenced in the SQL Server (I just put letters in my post to show what I was using)|||

mtarby:


SqlConnection myConnection = new SqlConnection("Provider=SQLOLEDB;Data Source=mssql;Initial Catalog= cat;UserId=ddd;Password=ddd;");

Edit/Delete Message

May be a silly question: can Provider key word be used in SqlConnection object? How about remove the Provider attribute from the connection string?

|||Without wanting to come across as too condescending, i'm taking it that your server is called mssql (and it's the only instance on your machine) and that the username and password are correct...?|||Yes, those are just placeholders I put in my post. The server, user name and password are all correct in my actual code|||

have you tried:

SqlConnection myConnection = new SqlConnection("Server= YourSrvr; Database=YourDB;UserId=ddd;Password=ddd;");|||I ended up adding an entry to my web.config file and its working fine now. Thanks for the help!

newbie connection problem

I am just starting with MSDE switching from access2002.
The installation was done on a server pc with:
password="sa",
Authentication Mode = SQL, and
DisableNetworkProtocols=0
On the server, I can connect to it fine, both via my app and the configure
wiz'd in the SYSTEM-DSNs list (off of control panel-Admin tools).
But from another PC on a two computer network, I cannot connect to it.
The configure wiz;d gives a double error:
SQLstate 1000 connaction failed ANd
SQLState 8001 error 17: serber does not exist or connection denied.
Do I need to specify anything other than server's name as the server's ID,
e.g. the hard disk label or...?
Do I need to somehow tell the server to allow a conection from another
PC? If yes, I can't find where that might be done?
I'd really appreciate ANY help on this frustrating problem.
Thanks in advance,
Run the program MSSQL\80\Tools\Binn\SVERNTCN and add TCP/IP (or whatever
matches the client side) to the server communication protocol.
|||Run the program MSSQL\80\Tools\Binn\SVERNTCN and add TCP/IP (or whatever
matches the client side) to the server communication protocol.

Saturday, February 25, 2012

Newbie - connection with a login not declared on the server

Hi,

I'm using a SQLServer 7 SP3.

I have noticed a connection of a login which is not declared on the
server (in NT authentification and SQLServer authentification).
I'm using the mixed mode authentification.
May be the login is affected to a administrator group.

Have you an idea of the way I could find why this person could login ?

FYA
RJPIf this is a domain user, using windows authentication he can log into the
system. If you are using SQL Server authentication/mixed mode you'll have to
add this user as a login to the Server.

--
- Anith
( Please reply to newsgroups only )

Monday, February 20, 2012

Newbee:reporting services gets: Connection could not be made to reportserver

When I try to deploy the sample reports solution to the local IIS on this
win2003 server, the message "A connection could not be made to the report
server http://a1900/Reportserver" appears.
I do this by:
1. Loading the SampleReports.sln into the vb.net IDE.
2. Right-clicking on the SampleReports solution, then selecting Properties,
then setting 'TargetServer URL'=http://a1900/Reportserver (it also fails
when I set it to 'http://localhost/ReportServer'
3. Right-clicking on the SampleReports solution, then selecting 'Deploy'.
4. No errors during the build phase.
The IIS Manager window shows in the left pane:
iis information services
- a1900 (local computer)
-FTP Sites
--...
-Web Sites
-- Default Web Site
--_vti_bin
--reports
-- reportServer
etc.
-Web Service Extensions
...
The IIS is on the same machine that I operate on and has entries of 'Default
Web Site\Reportserver' and 'Default Web Site\Reports'. The 'Default Website'
has 'Permissions' set to 'Full control' for administrators, as which I am
logged in.
I notice that the 'Reports' and 'ReportServer' entries do not have the blue
globe icon (?) that most of the other IIS folder entries have. Perhaps
that's the cause of my problem.
Do I have to add Web service extensions for Reporting Services?
Perhaps the Reporting services installation did not go right?
How do I find the correct url for the target server?
Where do I have to look.
What books to read?
Any help is greatly appreciated.
Thanks.Some questions & answers:
"Do I have to add Web service extensions for Reporting Services? "
No.
"How do I find the correct url for the target server?"
You are using the correct URL. To test it manually, navigate to the
following path:
http://localhost/ReportServer/ReportService.asmx
This is the webservice that the "Deploy" option uses based upon the
"TargetServer" property you set in the Project settings.
You should receive a SOAP response (XML) w-hen you navigate to that
URL. If you do not get this, then you may have an IIS configuration
problem. Because of the security configurations needed, I generally
just reinstall Reporting Services to make sure the Virtual Directory
and permissions are setup properly. In IIS 6, you should see what
looks like a cog/gear as the symbol for the ReportServer virtual
directory. The globes are for websites (DefaultWeb and such) which
isnt required.
One other thing to check is if your DefaultWebsite is using port 80,
and accepts "(All Unassigned)" IP addresses. Anything unusual in
these IIS settings may indicate part of your problem.
I hope this helps a bit...
~Lance Hunt
http://weblogs.asp.net/lhunt/