react-native-mssql
react-native-mssql copied to clipboard
[Unhandled promise rejection: TypeError: null is not an object (evaluating '_reactNativeMssql.default.connect')]
I am trying to connect to MSSQL server in my expo managed app but I am getting error : [Unhandled promise rejection: TypeError: null is not an object (evaluating '_reactNativeMssql.default.connect')]
post installing (npm install --save react-native-mssql) package , i linked the dependency via following command npx react-native link react-native-mssql
Let me know if I am missing anything.
This plugin is not tested or developed with expo in my so that's probably the cause of the issue
I am Having this error
Possible Unhandled Promise Rejection (id: 0): Error: Unknown server host name 'DESKTOP-AFMCR71\SQLEXPRESS'. Error: Unknown server host name 'DESKTOP-AFMCR71\SQLEXPRESS'. at Object.promiseMethodWrapper [as connect] (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.objectdetection&modulesOnly=false&runModule=true:2824:36) at Start._this.database (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.objectdetection&modulesOnly=false&runModule=true:703745:51) at Pressability._performTransitionSideEffects (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.objectdetection&modulesOnly=false&runModule=true:55107:15) at Pressability._receiveSignal (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.objectdetection&modulesOnly=false&runModule=true:55049:16) at onResponderRelease (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.objectdetection&modulesOnly=false&runModule=true:54956:20) at Object.invokeGuardedCallbackProd (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.objectdetection&modulesOnly=false&runModule=true:9657:16) at invokeGuardedCallback (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.objectdetection&modulesOnly=false&runModule=true:9761:37) at invokeGuardedCallbackAndCatchFirstError (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.objectdetection&modulesOnly=false&runModule=true:9765:31) at executeDispatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.objectdetection&modulesOnly=false&runModule=true:9837:9) at executeDispatchesInOrder (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.objectdetection&modulesOnly=false&runModule=true:9857:11)
my code is
import React, { Component } from 'react' import { View, StyleSheet, Dimensions } from 'react-native' import { Button, Text } from '@ui-kitten/components'; import MSSQL from 'react-native-mssql';
export default class Start extends Component {
constructor(props){
super(props)
}
database = () => {
const config = {
server: 'DESKTOP-AFMCR71\\SQLEXPRESS', //ip address of the mssql database
username: 'sa', //username to login to the database
password: '123456', //password to login to the database
database: 'Concil-Connect-Mobile', //the name of the database to connect to
// port: 1234, //OPTIONAL, port of the database on the server
// timeout: 5, //OPTIONAL, login timeout for the server
}
debugger;
const connected = MSSQL.connect(config);
console.log(connected);
}
// goToHome = () => {
// console.log("object")
// this.props.navigation.navigate('Home')
// }
render() {
return (
<View style={styles.container}>
<Text style={styles.text}> Image recognition </Text>
<Button
style={styles.button}
onPress={this.database}
>
START
</Button>
</View>
)
}
}
const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: 'white', justifyContent: 'center', alignItems: 'center' }, button: { backgroundColor: "#05676D", borderColor: '#05676D', width: Dimensions.get('screen').width/1.5, borderRadius: 10, marginTop: 10 }, text: { fontSize: 17, marginBottom: 20, color: 'white', } })